Really Quick C++ Question - Thanks!

Kenji4861

Banned
Jan 28, 2001
2,821
0
0
1
I'm trying to understand this class and this is what I see

function(){
/*some function*/
}

function(int i){
/*some function*/
}

~function(){
/*some function*/
}

If I want to send in a string of numbers to function. Is it possible?
 

singh

Golden Member
Jul 5, 2001
1,449
0
0
~function() is an object/class destructor called when the objects is deleted so it can perform its own post-deletion steps such as freeing dynamically allocated memory

To check for a negative number:

if(num < 0)
{
cout << "negative number\n";
}
else
{
cout << "0 or positive number\n";
}
 

Kenji4861

Banned
Jan 28, 2001
2,821
0
0
Thanks Singh, I don't know why I couldn't think of that negative number method. Anyways, here's another C++ question.
 

singh

Golden Member
Jul 5, 2001
1,449
0
0


<< Thanks Singh, I don't know why I couldn't think of that negative number method. Anyways, here's another C++ question. >>



What question?
 

Kenji4861

Banned
Jan 28, 2001
2,821
0
0
I have to send in a HUGE number, bigger than an unsigned int into these functions. The way I can think of is sending a string into the function, but one of them has no argument, one of them takes in an int as an argument, and the other is a destructor. So is this possible?
 

singh

Golden Member
Jul 5, 2001
1,449
0
0
Please clarify exactly what you mean. Can't you change the function(s) to your needs? How big is the number? You can't send anything to a destructor or a function that has no parameters.
 

Legendary

Diamond Member
Jan 22, 2002
7,019
1
0
sure, just write yourself another one

function((ap)string string){
/*some function*/
}

Don't forget to put the prototype in the class header.
If you use regular strings, take out the ap in the argument, otherwise leave it in for apstring