Re: GNU C++ code/concept help needed.

Ajay <ajayinddhar-/[email protected]> Mon, 19 Sep 2005 00:31:18 -0700 (PDT)
Newsgroups gmane.user-groups.linux.delhi.devel
Message-ID <[email protected]>

Rohit Kumar <rohitsz2-/[email protected]> wrote:
Greetings there,
need help with c++ code(actually 2).

First code is
here:http://www.geocities.com/rohitsz2/Student.txt

Problem:
unable to access a char pointer. can not understand
why.
just a guess: is initialization needed, if yes how to
set size for an run-time defined string length
pointer?

Second code is here:
http://www.geocities.com/rohitsz2/ProfileCustomized.txt

Problem:
Unable to intialize a default argument constructor
that has char pointer. so am unable to create objects
in main(indicated in the main function in the code)
got *strange* error for second code at compilation...

--------------------ERROR(second code)----------------

[rohitsz@localhost Constructor]$ g++
ProfileCustomized.cpp
ProfileCustomized.cpp: In function `int main()':
ProfileCustomized.cpp:339: error: jump to case label
ProfileCustomized.cpp:335: error: crosses
initialization of `ProfileCustomized pcn'
ProfileCustomized.cpp:349: error: jump to case label
ProfileCustomized.cpp:344: error: crosses
initialization of `ProfileCustomized pcnp'
ProfileCustomized.cpp:335: error: crosses
initialization of `ProfileCustomized pcn'
ProfileCustomized.cpp:363: error: jump to case label
ProfileCustomized.cpp:357: error: crosses
initialization of `ProfileCustomized pcnpr'
ProfileCustomized.cpp:344: error: crosses
initialization of `ProfileCustomized pcnp'
ProfileCustomized.cpp:335: error: crosses
initialization of `ProfileCustomized pcn'
ProfileCustomized.cpp:366: error: jump to case label
ProfileCustomized.cpp:357: error: crosses
initialization of `ProfileCustomized pcnpr'
ProfileCustomized.cpp:344: error: crosses
initialization of `ProfileCustomized pcnp'
ProfileCustomized.cpp:335: error: crosses
initialization of `ProfileCustomized pcn'
[rohitsz@localhost Constructor]$

--------------------ERROR(second code)----------------

PS: sorry for not including line-numbers in the
code-links, but the error place are commented(//).

kindly help,

thanks,
ro

I think before storing strings in the char*, memory should be created by ne=
w(size of string +1)


		=

---------------------------------
Yahoo! for Good
 Click here to donate to the Hurricane Katrina relief effort. =