allocation problem with new
Hi ,
I have an allocation problem with new for a class object.Here the code I am in trouble with ;
......
void As::innsert(const string & x, As* & t) const
{if(t==NULL)
t=new As(x,NULL,NULL);
...} where As is a class object and I want to allocate space however an error occurs such that: (undefined reference to `As::As[in-charge](std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, As*, As*)').If there is someone who have an idea about this problem please help me :( .
Thanks...
[560 byte] By [
korhin] at [2007-11-11 7:31:43]

# 1 Re: allocation problem with new
Check the declarartion of As's constructor. Does it have a constructor that takes three parameters? If so, what are their types? Are they const qualified? Are they pointers? In short, make sure that the arguments provided in the new-expression match the parameters of the constructor.
Danny at 2007-11-11 21:02:06 >

# 2 Re: allocation problem with new
yes, i have noticed that the problem is about constructor but when i try to fix it ,i couldn't ...Now the compiler says that ;
/usr/lib/gcc-lib/i486-linux-gnu/3.3.6/../../../crt1.o: In function `_start':
../sysdeps/i386/elf/start.S:115: undefined reference to `main'
collect2: ld returned 1 exit status
does this occur due to same problem ? if so , i couldn't think no more choice to change the constructor. If you have any idea please help me !!!!
Thanks...
korhin at 2007-11-11 21:03:13 >

# 3 Re: allocation problem with new
the linkewr error has nothing to do with the As constructor. Your program doesn't have a main() function or your linker isn't properly configured.
Danny at 2007-11-11 21:04:18 >

# 4 Re: allocation problem with new
yeah,I haven't a main() function yet and I think so the problem is about this :o .As you can see ,I am novice and I don't have any idea about linker error . If you refer some online resources about this , I am glad. Thanks for your help...
korhin at 2007-11-11 21:05:13 >

# 5 Re: allocation problem with new
You dont have a program until you have
int main()
{
//the program starts here!
}
jonnin at 2007-11-11 21:06:18 >

# 6 Re: allocation problem with new
Ok I see. I have three seperate classes and I intend to use them in a main() function and before completing the whole program I want to try whether they are working correctly or not. Is this a bad programming?? :o
Thanks...
korhin at 2007-11-11 21:07:11 >

# 7 Re: allocation problem with new
No every 'module' should be tested as soon as possible. Large projects cannot be done any other way -- you must test everything before putting it together or the assembled program will be impossible to debug.
jonnin at 2007-11-11 21:08:22 >
