Hello Guest, please login or register.
Did you miss your activation email?
Login with username, password and session length.

Pages: [1] 2   Go Down

Author Topic: Get an error when I try to compile this(C++)  (Read 4982 times)

0 Members and 1 Guest are viewing this topic.
Get an error when I try to compile this(C++)
« on: August 19, 2006, 08:57:24 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 6206
Code: [Select]
//Oefening1: Klassen en objecten
#include <iostream.h>

//De klassendeclaratie
class Breuk
{
private:
int teller,noemer;//Klasse-variablen

public:
void Ingeven();//Methoden
void Tonen();
};

//De klassedefinitie
void Breuk::Ingeven()
{
cout<<endl<<"Geef de waarden van teller en noemer:";
cin>>teller>>noemer;
}

void Breuk::Tonen()
{
cout<<endl<<"De breuk is :"<<teller<<"/"<<noemer<<endl;
}

//Het hoofdprogramma
void main()
{
Breuk B1;
B1.Ingeven();
B1.Tonen();
}

The error is
Quote
------ Build started: Project: Oefening1, Configuration: Debug Win32 ------
Compiling...
Oefening1.cpp
c:\documents and settings\hyrule_boy\c++\oefingen\visual c++ boek\oefening1\oefening1\oefening1.cpp(2) : fatal error C1083: Cannot open include file: 'iostream.h': No such file or directory
Build log was saved at "file://c:\Documents and Settings\Hyrule_boy\C++\Oefingen\Visual C++ boek\Oefening1\Oefening1\Debug\BuildLog.htm"
Oefening1 - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Logged
Re: Get an error when I try to compile this(C++)
« Reply #1 on: August 19, 2006, 09:30:31 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 570
I dont know what your trying to do here,but when i compiled this it gave me so many errors I blew up!



Linkw
Logged

Pedlya

Pederp
Re: Get an error when I try to compile this(C++)
« Reply #2 on: August 19, 2006, 09:34:08 pm »
  • Vote for Harvey!~
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 2408
HB Very few people here speak german, let alone speak german and c++, so english plz  ???
Logged
So what! I wanna get out! 'Cos there's so much out there! So many different people, living different lives! Incredibly good guys, bad guys... Folks completely different from us! It's one huge melting pot! See, it's not about success, dying in the streets, who's better, who's not! I just want to be a part of it! I realized that even if I've no connections, no talent, even if I'm one big loser, I want to use my hands and feet to think and move, to shape my own life! We can just die here or we can try, see what we've got!
Re: Get an error when I try to compile this(C++)
« Reply #3 on: August 19, 2006, 09:36:08 pm »
  • =/
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 2284
HB Very few people here speak german, let alone speak german and c++, so english plz  ???
Actually, its dutch.
Logged
Re: Get an error when I try to compile this(C++)
« Reply #4 on: August 19, 2006, 09:40:44 pm »
  • *
  • Reputation: +3/-0
  • Offline Offline
  • Gender: Male
  • Posts: 6629
iostream.h is depreciated use iostream.
Logged
Re: Get an error when I try to compile this(C++)
« Reply #5 on: August 19, 2006, 09:43:08 pm »
  • that old name
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 789
Quote
fatal error C1083: Cannot open include file: 'iostream.h': No such file or directory

It seems that your compiler cannot find iostream.h ..or at least that is the obvious error that your.. 'error' is telling me...
(this may be because, as Helios stated, it has been depreciated, and your compiler has maybe stopped supporting/supplying it)

Use <iostream> instead, and use int main() versus void main().
You should end with a 'return 0;' as well. Like so:

Code: [Select]
#include <iostream>
using namepsace std;


int main()
{
...
return 0;
}
« Last Edit: August 19, 2006, 10:17:04 pm by Sterlin254 »
Logged
Re: Get an error when I try to compile this(C++)
« Reply #6 on: August 19, 2006, 10:02:00 pm »
  • IBV
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Female
  • Posts: 1075
and use main(), not void main().

you probably mean "int main()" and then he need to (or may?) end the main-function with "return 0;" too.
Logged
My signature is empty.
Re: Get an error when I try to compile this(C++)
« Reply #7 on: August 19, 2006, 10:02:47 pm »
  • that old name
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 789
and use main(), not void main().

you probably mean "int main()" and then he need to (or may?) end the main-function with "return 0;" too.

Yes, and yes...
. . . .*quickly edits post*
Logged
Re: Get an error when I try to compile this(C++)
« Reply #8 on: August 20, 2006, 03:58:20 am »
  • The Broken King
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 1259
It's as helios said. If you had cross checked with other code, you would have seen that they use <iostream>, not <iostream.h>.

the void main probably isn't a problem, although int is used more these days so that you can return the success or failure of your program.
Logged
  • Broken Kings [Temp Site]
Re: Get an error when I try to compile this(C++)
« Reply #9 on: August 20, 2006, 08:59:41 am »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 6206
So I changed what you people suggested but now I get 3 errors the source code is now.
Code: [Select]
//Oefening1: Klassen en objecten
#include <iostream>

//De klassendeclaratie
class Breuk
{
private:
int teller,noemer;//Klasse-variablen

public:
int Ingeven();//Methoden
int Tonen();
};

//De klassedefinitie
int Breuk::Ingeven()
{
cout<<endl<<"Geef de waarden van teller en noemer:";
cin>>teller>>noemer;
}

int Breuk::Tonen()
{
cout<<endl<<"De breuk is :"<<teller<<"/"<<noemer<<endl;
}

//Het hoofdprogramma
int main()
{
Breuk B1;
B1.Ingeven();
B1.Tonen();
return 0;
}
The errors
Quote
------ Build started: Project: Oefening1, Configuration: Debug Win32 ------
Compiling...
Oefening1.cpp
c:\documents and settings\hyrule_boy\c++\oefingen\visual c++ boek\oefening1\oefening1\oefening1.cpp(18) : error C2065: 'cout' : undeclared identifier
c:\documents and settings\hyrule_boy\c++\oefingen\visual c++ boek\oefening1\oefening1\oefening1.cpp(18) : error C2065: 'endl' : undeclared identifier
c:\documents and settings\hyrule_boy\c++\oefingen\visual c++ boek\oefening1\oefening1\oefening1.cpp(19) : error C2065: 'cin' : undeclared identifier
Build log was saved at "file://c:\Documents and Settings\Hyrule_boy\C++\Oefingen\Visual C++ boek\Oefening1\Oefening1\Debug\BuildLog.htm"
Oefening1 - 3 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Logged
Re: Get an error when I try to compile this(C++)
« Reply #10 on: August 20, 2006, 09:03:55 am »
  • *
  • Reputation: +3/-0
  • Offline Offline
  • Gender: Male
  • Posts: 6629
You need to declare the namespace you wish to use. Put 'using namespace std' below your include statements..
Logged
Re: Get an error when I try to compile this(C++)
« Reply #11 on: August 20, 2006, 10:50:46 am »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 6206
You need to declare the namespace you wish to use. Put 'using namespace std' below your include statements..
Now it says
Quote
------ Build started: Project: Oefening1, Configuration: Debug Win32 ------
Compiling...
Oefening1.cpp
c:\documents and settings\hyrule_boy\c++\oefingen\visual c++ boek\oefening1\oefening1\oefening1.cpp(7) : error C2143: syntax error : missing ';' before '<class-head>'
Build log was saved at "file://c:\Documents and Settings\Hyrule_boy\C++\Oefingen\Visual C++ boek\Oefening1\Oefening1\Debug\BuildLog.htm"
Oefening1 - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Logged
Re: Get an error when I try to compile this(C++)
« Reply #12 on: August 20, 2006, 10:56:55 am »
  • *
  • Reputation: +3/-0
  • Offline Offline
  • Gender: Male
  • Posts: 6629
You need to learn to debug things yourself, as around 80% of programming tends to be debugging and with that amount of debugging you can't expect to ask other people to solve the problems for you. This error is fairly simple to understand, let me explain it.

c:\documents and settings\hyrule_boy\c++\oefingen\visual c++ boek\oefening1\oefening1\oefening1.cpp(7) : error C2143: syntax error : missing ';' before '<class-head>'

That is the file the error occured in.

c:\documents and settings\hyrule_boy\c++\oefingen\visual c++ boek\oefening1\oefening1\oefening1.cpp(7) : error C2143: syntax error : missing ';' before '<class-head>'

That is the line the error occured on.

c:\documents and settings\hyrule_boy\c++\oefingen\visual c++ boek\oefening1\oefening1\oefening1.cpp(7) : error C2143: syntax error : missing ';' before '<class-head>'

This is the internal error code, you can use google to get more detailed infomation about the error by using this code.

c:\documents and settings\hyrule_boy\c++\oefingen\visual c++ boek\oefening1\oefening1\oefening1.cpp(7) : error C2143: syntax error : missing ';' before '<class-head>'

This is the error discription it explains how the error was caused, in this case its because there is a missing semi colon.
« Last Edit: August 20, 2006, 10:58:57 am by Helios »
Logged
Re: Get an error when I try to compile this(C++)
« Reply #13 on: August 20, 2006, 11:28:05 am »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 6206
I do not expect that people here solve my problem. I made this code from a book I bought. And I checked several times if I typed it good. And I don't see what I did wrong.
Logged
Re: Get an error when I try to compile this(C++)
« Reply #14 on: August 20, 2006, 01:39:27 pm »
  • IBV
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Female
  • Posts: 1075
I do not expect that people here solve my problem. I made this code from a book I bought. And I checked several times if I typed it good. And I don't see what I did wrong.

It's because the books are old.

It's as helios said. If you had cross checked with other code, you would have seen that they use <iostream>, not <iostream.h>.

the void main probably isn't a problem, although int is used more these days so that you can return the success or failure of your program.

it's "int main". Everything else is not following the standard. By not following the standard you can't guarantee that the code will compile on any compiler on any system.
Logged
My signature is empty.
Re: Get an error when I try to compile this(C++)
« Reply #15 on: August 20, 2006, 02:34:32 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 6206
Quote
c:\documents and settings\hyrule_boy\c++\oefingen\visual c++ boek\oefening1\oefening1\oefening1.cpp(7) : error C2143: syntax error : missing ';' before '<class-head>'
There is no <class-head> in the source code.
Logged
Re: Get an error when I try to compile this(C++)
« Reply #16 on: August 21, 2006, 01:44:23 am »
  • The Broken King
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 1259
Check your code for any syntax errors. There is something wrong with it. No offense, but this is a very simple program, and you have to learn to debug for yourself. If you ever want to do anything with your code [like direct x, networking, opengl, windows programming, classes, etc.] you have to learn to look for your own bugs.

Seriously, I've literally spent hours trying to solve a single bug before. It's part of the programming experience. You have to learn to figure out what's wrong on your own.
Logged
  • Broken Kings [Temp Site]
Re: Get an error when I try to compile this(C++)
« Reply #17 on: August 21, 2006, 01:54:33 am »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 2245
mind showing the updated version of your code?
Logged
Re: Get an error when I try to compile this(C++)
« Reply #18 on: August 21, 2006, 08:10:34 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 6206
Check your code for any syntax errors. There is something wrong with it. No offense, but this is a very simple program, and you have to learn to debug for yourself. If you ever want to do anything with your code [like direct x, networking, opengl, windows programming, classes, etc.] you have to learn to look for your own bugs.

Seriously, I've literally spent hours trying to solve a single bug before. It's part of the programming experience. You have to learn to figure out what's wrong on your own.
I know this is a simple program its the first lession in the book I only typed what stand there. And Bongo Bob the latest version is at the bottom of page 1.

EDIT: THIS IS EXTREMELY WEIRD!!! When I used this code
Code: [Select]
//Oefening1: Klassen en objecten
#include <iostream.h>

//De klassendeclaratie
class Breuk
{
private:
int teller,noemer;//Klasse-variablen

public:
void Ingeven();//Methoden
void Tonen();
};

//De klassedefinitie
void Breuk::Ingeven()
{
cout<<endl<<"Geef de waarden van teller en noemer:";
cin>>teller>>noemer;
}

void Breuk::Tonen()
{
cout<<endl<<"De breuk is :"<<teller<<"/"<<noemer<<endl;
}

//Het hoofdprogramma
int main()
{
Breuk B1;
B1.Ingeven();
B1.Tonen();
return 0;
}
It works fine in Dev-C++ but when I try to compile it in Microsoft Visual C++ 2005 proffesional edition I get errors. O____O
« Last Edit: August 21, 2006, 08:16:12 pm by Hyrule_boy »
Logged
Re: Get an error when I try to compile this(C++)
« Reply #19 on: August 21, 2006, 08:31:43 pm »
  • *
  • Reputation: +3/-0
  • Offline Offline
  • Gender: Male
  • Posts: 6629
Quote
It works fine in Dev-C++ but when I try to compile it in Microsoft Visual C++ 2005 proffesional edition I get errors. O____O
Are you sure you are not compiling under .NET, (VC++ 2005 can compile both native and IL executable images), as .NET has some quite significant changes.
« Last Edit: August 21, 2006, 08:37:13 pm by Helios »
Logged
Pages: [1] 2   Go Up

 


Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved



Page created in 0.067 seconds with 74 queries.

anything