| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Begginer
Hi there, im new to c++. I got a book on c++ and im using the new Visual C++ Express 2005 Beta 2.
I tried to make this program just like the book told me, but it didnt work. I'll post the source code and error. Code:
/* '01 Main.cpp' */
/* Input output stream header file */
#include <iostream>
/* Start */
main (void)
{
std::cout << "Hello all you happy people" << std::endl;
return 0;
}
Thats the source, and heres the error it gives me Code:
1>------ Build started: Project: Chapter_01, Configuration: Debug Win32 ------ 1>Compiling... 1>01 Main.cpp 1>e:\book\chapter_01\chapter_01\01 main.cpp(8) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1>Build log was saved at "file://e:\Book\Chapter_01\Chapter_01\Debug\BuildLog.htm" 1>Chapter_01 - 1 error(s), 0 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== Anyone know how i can fix this? Thanks |
|
#2
|
|||
|
|||
|
try sticking 'int ' before the main:
Code:
int main (void)
{
std::cout << "Hello all you happy people" << std::endl;
return 0;
}
|
|
#3
|
|||
|
|||
|
just write return; otherwise write int before main
|
|
#4
|
||||
|
||||
|
Does the example code in your book tell you to put std:: before the cout<< statement. I use visual studio 2005 beta and All I have to write is cout<<.
|
|
#5
|
|||
|
|||
|
you should need the std:: prefix, unless you put a using namespace std; or a using std::cout; at the top of the program...
|
|
#6
|
|||
|
|||
|
i think it should be like
Code:
#include <iostream>
using namespace std;
int main (void)
{
std::cout << "Hello all you happy people" << std::endl;
return 0;
}
so u think u should add using namespace std; but w/e im a newbie Last edited by B-Con : July 19th, 2005 at 03:58 AM. Reason: added a closing [code] tag ;) |
|
#7
|
|||
|
|||
|
Try this:
#include <iostream> using namespace std; int main() { cout<< "Hello all you happy people"<< endl; return 0; } I program C++ in unix and it might be different in the program you are using. Sorry if this dosen't work. theguz |
![]() |
| Viewing: Dev Articles Community Forums > Programming > C/C++ Help > Begginer |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|