So what function have we been working on thus far? Main() right? OK now we are going to go a step farther and create a new function and call upon that fuction withi main. There are two ways of doing this, you can use a process called Prototyping or you could put the desired function above the main function.
#include
//Building fuctions
using namespace std;
//This is almost like building a class.
void World(){
cout <<"This is a example"<
}
int main()
{
World(); //This calls the World function
return 0;
}
With prototyping we do the same thing except:
#include
//Building fuctions
using namespace std;
//This is almost like building a class.
void World();
/*Remember that the complier works from top to bottom there is another way of doing this.
It is called prototyping*/
}
int main()
{
World(); //This calls the World function
return 0;
}
World(){
cout<<"This is prototyping"<
} If you are having trouble thenewboston has a great video tutorial on this. Click here to go to that video.
No comments:
Post a Comment