Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

FUNCTIONS BETWEEN VARIABLES C++ PROJECT


  • Please log in to reply
8 replies to this topic

#1 pixies

pixies

  • Members
  • 4 posts
  • OFFLINE
  •  
  • Local time:12:31 PM

Posted 16 May 2013 - 10:46 AM

Hello !

 

I have to create a source code in c++ in order to add ,  subtract , divide and multiple variables such as strings , integers , boolean and decimal .

 

I am supposed to create a struct with name , value and type so that I can save my variables. (with static arraylength)

 

However I cannot do this.

 

Could someone give me an example ?


Edited by pixies, 16 May 2013 - 10:46 AM.


BC AdBot (Login to Remove)

 


#2 Billy O'Neal

Billy O'Neal

    Visual C++ STL Maintainer


  • Malware Response Team
  • 12,304 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Redmond, Washington
  • Local time:12:31 PM

Posted 16 May 2013 - 01:25 PM

What do you define as a "decimal"? C++ does not recognize such a type.

What would you define addition, subtraction, multiplication, or division to do on strings?

Billy3
Twitter - My statements do not establish the official position of Microsoft Corporation, and are my own personal opinion. (But you already knew that, right?)
Posted Image

#3 pixies

pixies
  • Topic Starter

  • Members
  • 4 posts
  • OFFLINE
  •  
  • Local time:12:31 PM

Posted 16 May 2013 - 01:42 PM

when i add string and integer i concatenate them



when i add integr and string i have to concatenate them just like they were one string



#4 Billy O'Neal

Billy O'Neal

    Visual C++ STL Maintainer


  • Malware Response Team
  • 12,304 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Redmond, Washington
  • Local time:12:31 PM

Posted 16 May 2013 - 01:43 PM

Ok, then convert the integer to a string, and concatenate them.

(This sounds an awful lot like a homework question...)

Billy3
Twitter - My statements do not establish the official position of Microsoft Corporation, and are my own personal opinion. (But you already knew that, right?)
Posted Image

#5 pixies

pixies
  • Topic Starter

  • Members
  • 4 posts
  • OFFLINE
  •  
  • Local time:12:31 PM

Posted 16 May 2013 - 01:46 PM

ΟΚ , ι  d like to ask something else ..... How can i create a number of variables such as integers and strings ? The mumber is specified by the user s willing



#6 Billy O'Neal

Billy O'Neal

    Visual C++ STL Maintainer


  • Malware Response Team
  • 12,304 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Redmond, Washington
  • Local time:12:31 PM

Posted 16 May 2013 - 03:34 PM

You don't. You create an array, which is a single variable capable of containing multiple values, into which you place the user entered values. Consider using standard library primitives designed for this such as std::vector designed for this purpose.

Edited by Billy O'Neal, 16 May 2013 - 03:35 PM.

Twitter - My statements do not establish the official position of Microsoft Corporation, and are my own personal opinion. (But you already knew that, right?)
Posted Image

#7 pixies

pixies
  • Topic Starter

  • Members
  • 4 posts
  • OFFLINE
  •  
  • Local time:12:31 PM

Posted 16 May 2013 - 04:23 PM

thank you very much !!!



#8 AceInfinity

AceInfinity

  • Members
  • 30 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Canada
  • Local time:12:31 PM

Posted 24 May 2013 - 10:00 PM

Where have you gotten on this? Let's see what you've done so far and maybe we can help you further.


mvp.png
Microsoft MVP .NET Programming - (2012 - Present)
®Crestron DMC-T Certified Automation Programmer


#9 annaharris

annaharris

  • Members
  • 12 posts
  • OFFLINE
  •  
  • Gender:Female
  • Location:USA
  • Local time:01:01 AM

Posted 03 June 2013 - 07:56 AM

You can create your own functions for addition, subtraction, division and multiplication and use those functions anywhere in the program.

 






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users