Page 1 of 1
multiple .cpp example
Posted: Sun Feb 22, 2009 10:40 am
by opearn
here is my example,
it shows you how to initialize new commands e.g in my main.cpp i've written
hello();
to write hello world on the screen...
it is extremely useful when making a long program.
heres the link
btw sorry about double post... its relevent to both categories...
Re: multiple .cpp example
Posted: Thu Mar 19, 2009 6:41 pm
by susanspy
hello all,
my name is susan, i am newbie here, in this program something is wrong but i dont know what is wrong?
#include<iostream.h>
main()
{
int num;
cout<<" Enter a number :";
cin>> num;
cout << Number "<< num;
}
}
please help
cheers!!!!!!!!!!
keyword software~
keyword tool
search keyword~
track keyword
Re: multiple .cpp example
Posted: Fri Mar 20, 2009 12:23 am
by weirdfox
Fast analysis of the code:
- The main has no type (and no return).
- There is too many closing bracket.
- The good header to include (in standard C++) is not <iostream.h>, but <iosteam> (the .h version, if it's still there, should be tag as deprecated by the compiler)
- The functions cin and cout require to have a prefix "std::" as they are in the std namespace ( ou simply add "using namespace std;" before your main)
Here's someting that would compile :
Code: Select all
#include <iostream>
int main()
{
int num;
std::cout << " Enter a number :";
std::cin >> num;
std::cout << "Number " << num;
return 0;
}