TheEliteOne
04-23-2010, 03:45 PM
Tut by TheEliteOne
Calling Functions in C++
Lets say we want a title, like this:
TheEliteOne's Example!
at the top of the screen, but we don't want to type in cout<<"TheEliteOne's Example!\n\n"; every time. We can use a function and call it every time we want to. Like this:
#include <iostream.h>
void title()
{
cout<<"TheEliteOne's Example!\n\n";
}
void pause()
{
system("pause");
}
void cls()
{
system("cls");
}
int main()
{
First:
cls(); //Calls are cls function.
title(); //Calls are title function.
cout<<"See.. not that hard right?\n\n";
pause(); //Calls are pause function.
goto First;
}
I don't know about but I would rather type in some thing like "title();" than "cout<<TITLE OF YOUR PROGRAM\n\n"; " every time I wanted to ;) hope it helped.
Calling Functions in C++
Lets say we want a title, like this:
TheEliteOne's Example!
at the top of the screen, but we don't want to type in cout<<"TheEliteOne's Example!\n\n"; every time. We can use a function and call it every time we want to. Like this:
#include <iostream.h>
void title()
{
cout<<"TheEliteOne's Example!\n\n";
}
void pause()
{
system("pause");
}
void cls()
{
system("cls");
}
int main()
{
First:
cls(); //Calls are cls function.
title(); //Calls are title function.
cout<<"See.. not that hard right?\n\n";
pause(); //Calls are pause function.
goto First;
}
I don't know about but I would rather type in some thing like "title();" than "cout<<TITLE OF YOUR PROGRAM\n\n"; " every time I wanted to ;) hope it helped.