|
From: Rafael C. <rc...@un...> - 2002-12-06 13:40:16
|
You should use prototypes to define the functions you need
in your main function.=20
Define your prototypes before the main function or
in another file (.h). The code for your functions=20
can be after your "main".
In your case, the prototypes would be:
void FuctionOne(void);
void FuctionTwo(void);
Basically, they are the headers of functions with
a ";" at the end.
So you have, for instance:
1) prototypes
void f1 (void);
void f2 (int);
2) main function
void main() {
...
f1();
f2("an integer");
...
}
3) implementation of the functions you define
void f1 (void) {
int myInt;=20
...
f2(myInt);
...
}
void f2 (int anInt) {
...
}
Read more about prototypes and functions in
http://www.cplusplus.com/doc/tutorial/tut2-2.html
Regards,
Rafael=20
C=F3pia Dondolo Mpho <MDo...@OL...>:
> Hi all,
>=20
> I am in the process of learning C++. I have been practising, writing my
> own
> functions and using main() only to call those function. I also use
> those
> functions to call up other function....
>=20
> //e.g.: function (1)
>=20
> void FuctionOne(void)
> {
> int Answer=20
> cout<<"Are you ready...<press 1 for yes and 2 for no> ";
> cin>>Answer;
> if(Answer=3D=3D1)
> {
> cout<<"\nI am glad that you are";
> }
>=20
> else
> {
> FuctionTwo();
> }
>=20
> }
>=20
> //Here I have my=20
> //FunctionTwo
>=20
> Now I find that the compiler flags
> an
> error msg that FunctionTwo has not been declared. it only works when I
> take
> FunctionTwo() and put it on top of =20
> FunctionOne()....i am I doing
> something
> wrong? The thing is I might decide halfway through my functions That i
> want
> function x to call function=20
> y. Now If i have to readjust my
> functions half way through, i will loose track of what I am
> doing.....Please
> help anybody =20
>=20
> =20
> Mpho Dondolo
> Support Analyst
> CSC Computer Sciences (South Africa) (Pty) Ltd
> Tel: +27 21 503030164
> cell: +27 84 3371468
> Fax: +27 21 5095619
> Email:MDo...@ol...
> Email: MDo...@cs...
> =20
>=20
>=20
|