Re: [Dev-C++] newbie questions without answer
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Carlos d. M. <cg...@wo...> - 2002-08-11 12:54:11
|
newbiequestion.cpp
struct employ{
char *first;
char *second;
date eyear; /*i want to use a reference to the year in the first
struct
but then i get an error message from the compiler since i
didn't
initialize eyear!! how am i to get rid of this
problem??*/
I have no problems compiling it.
employvar.eyear.(day/month/year)= x;
Or
date *eyear
employvar.eyear->day=x.
Or
date *eyear; in employer struct.
datevar.day = x;
employvar.eyear = datevar;
Or datevar.day=x;
datevar.eyear = &datevar;
The other question about shorter way. I don't understand.
In the stringclass what happens is that when you modify the += operator,
so the string of the left hand string object is no midified you make
that neither it size is modified (evidently), but then, ine the code, at
line 178 - 190, the code assumes that function has not been changed (you
did not adapted it to your modifications), so as it wants to output the
substrings from a subscript to another position, and the positions are
not found through object's functions, they are put ad hoc, the code at
this lines are intended so you had just added s2 to s1, so s1 is "happy
birthday to you", which has 21 characters, and there the code is
"substring from 0, 14 and after from 15, 0", which are ranges that would
be in s1, but you modified it in a way such now s1 is "happy", five
chars, so when you ask for range 15,0 you're giving a range which is
out of the bounds of s1.
The burda nie ref var, that's the way....
|