boek gekocht met borland compiler kan ik ook een andere gebruiken

Status
Niet open voor verdere reacties.

kevin10

Gebruiker
Lid geworden
22 jan 2008
Berichten
344
Ik heb het boek aan de slag met C++ gekocht van gertjan laan.
alleen ik gebruik windows 7 en er zit een borland compiler bij en die krijg ik niet aan de praat in windows 7 in xp werkt die wel. Nu is mijn vraag kan ik ook een andere compiler gebruiken zoals microsoft visual C++ dat ik niet de codes in de commandpromp hoef in te voeren.
en werken alle codes van het boek dan nog? of zit er een verschil tussen de codes van de 2 compilers.
 
aangezien de 2 programma's dezelfde programmeertaal gebruikt (C++ is hier de programmeertaal), blijven de commands hetzelfde.

En microsh*t's Visual studio C++ is erg aan te raden, werkt op de windows van versie 2000 (9 jaar geleden) tot de huidige 7
 
Laatst bewerkt:
Bedankt voor je snelle reactie :thumb: hoef ik gelukkig niet een ander boek te kopen ik heb in de tussentijd microsoft visual C++ geinstalleerd het eerste programmatje werkte alleen de 2de geeft een fout en ik heb geen flauw idee waar die zit.
Dit is mijn code:
Code:
#include <iostream>
using namespace std;

int main()
{
 string naam1, naam2;
 int leeftijd1, leeftijd2;

 cout << "Wat is de naam van de 1e persoon?" << endl;
 getline( cin, naam1 );

 cout << "Wat is zijn/haar leftijd?" << endl;
 cin >> leeftijd1;
 cin.get();

 cout << "Wat is de naam van de 2e persoon?" << endl;
 getline( cin,naam2 );

 cout << "Wat is zijn/haar leeftijd?" << endl;
 cin >> leeftijd2;
 cin.get();

 cout << "Alle gegevens zijn ingevoerd!" << endl;
 cout << "Hier volgt het resultaat:" << endl << endl;

 cout << "De personen " << naam1 << " en " << naam2
	 << " zijn samen "
	 << (leeftijd1 + leeftijd2) << " jaar oud" << endl;

 cout <<"Druk op Enter om het programma te beeindigen";
 cin.get();
 return 0;
}
en dit wat er gebeurd als ik het goed zie is het iets met getline alleen staat het er precies hetzelfde als in het boek of ik zie iets over het hoofd
Code:
1>------ Build started: Project: opdracht2, Configuration: Debug Win32 ------
1>Compiling...
1>main.cpp
1>c:\users\kevin\documents\visual studio 2008\projects\opdracht2\opdracht2\main.cpp(10) : error C3861: 'getline': identifier not found
1>c:\users\kevin\documents\visual studio 2008\projects\opdracht2\opdracht2\main.cpp(17) : error C3861: 'getline': identifier not found
1>c:\users\kevin\documents\visual studio 2008\projects\opdracht2\opdracht2\main.cpp(26) : error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion)
1>        c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(653): could be 'std::basic_ostream<_Elem,_Traits> &std::operator <<<char,std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,const char *)'
1>        with
1>        [
1>            _Elem=char,
1>            _Traits=std::char_traits<char>
1>        ]
1>        c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(700): or       'std::basic_ostream<_Elem,_Traits> &std::operator <<<char,std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,char)'
1>        with
1>        [
1>            _Elem=char,
1>            _Traits=std::char_traits<char>
1>        ]
1>        c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(738): or       'std::basic_ostream<_Elem,_Traits> &std::operator <<<std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,const char *)'
1>        with
1>        [
1>            _Elem=char,
1>            _Traits=std::char_traits<char>
1>        ]
1>        c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(785): or       'std::basic_ostream<_Elem,_Traits> &std::operator <<<std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,char)'
1>        with
1>        [
1>            _Elem=char,
1>            _Traits=std::char_traits<char>
1>        ]
1>        c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(909): or       'std::basic_ostream<_Elem,_Traits> &std::operator <<<std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,const signed char *)'
1>        with
1>        [
1>            _Elem=char,
1>            _Traits=std::char_traits<char>
1>        ]
1>        c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(916): or       'std::basic_ostream<_Elem,_Traits> &std::operator <<<std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,signed char)'
1>        with
1>        [
1>            _Elem=char,
1>            _Traits=std::char_traits<char>
1>        ]
1>        c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(923): or       'std::basic_ostream<_Elem,_Traits> &std::operator <<<std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,const unsigned char *)'
1>        with
1>        [
1>            _Elem=char,
1>            _Traits=std::char_traits<char>
1>        ]
1>        c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(930): or       'std::basic_ostream<_Elem,_Traits> &std::operator <<<std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,unsigned char)'
1>        with
1>        [
1>            _Elem=char,
1>            _Traits=std::char_traits<char>
1>        ]
1>        c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(170): or       'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(std::basic_ostream<_Elem,_Traits> &(__cdecl *)(std::basic_ostream<_Elem,_Traits> &))'
1>        with
1>        [
1>            _Elem=char,
1>            _Traits=std::char_traits<char>
1>        ]
1>        c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(176): or       'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(std::basic_ios<_Elem,_Traits> &(__cdecl *)(std::basic_ios<_Elem,_Traits> &))'
1>        with
1>        [
1>            _Elem=char,
1>            _Traits=std::char_traits<char>
1>        ]
1>        c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(183): or       'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(std::ios_base &(__cdecl *)(std::ios_base &))'
1>        with
1>        [
1>            _Elem=char,
1>            _Traits=std::char_traits<char>
1>        ]
1>        c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(190): or       'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(std::_Bool)'
1>        with
1>        [
1>            _Elem=char,
1>            _Traits=std::char_traits<char>
1>        ]
1>        c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(210): or       'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(short)'
1>        with
1>        [
1>            _Elem=char,
1>            _Traits=std::char_traits<char>
1>        ]
1>        c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(243): or       'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(unsigned short)'
1>        with
1>        [
1>            _Elem=char,
1>            _Traits=std::char_traits<char>
1>        ]
1>        c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(263): or       'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(__w64 int)'
1>        with
1>        [
1>            _Elem=char,
1>            _Traits=std::char_traits<char>
1>        ]
1>        c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(288): or       'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(__w64 unsigned int)'
1>        with
1>        [
1>            _Elem=char,
1>            _Traits=std::char_traits<char>
1>        ]
1>        c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(308): or       'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(long)'
1>        with
1>        [
1>            _Elem=char,
1>            _Traits=std::char_traits<char>
1>        ]
1>        c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(328): or       'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(__w64 unsigned long)'
1>        with
1>        [
1>            _Elem=char,
1>            _Traits=std::char_traits<char>
1>        ]
1>        c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(349): or       'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(__int64)'
1>        with
1>        [
1>            _Elem=char,
1>            _Traits=std::char_traits<char>
1>        ]
1>        c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(369): or       'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(unsigned __int64)'
1>        with
1>        [
1>            _Elem=char,
1>            _Traits=std::char_traits<char>
1>        ]
1>        c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(390): or       'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(float)'
1>        with
1>        [
1>            _Elem=char,
1>            _Traits=std::char_traits<char>
1>        ]
1>        c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(410): or       'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(double)'
1>        with
1>        [
1>            _Elem=char,
1>            _Traits=std::char_traits<char>
1>        ]
1>        c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(430): or       'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(long double)'
1>        with
1>        [
1>            _Elem=char,
1>            _Traits=std::char_traits<char>
1>        ]
1>        c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(450): or       'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(const void *)'
1>        with
1>        [
1>            _Elem=char,
1>            _Traits=std::char_traits<char>
1>        ]
1>        c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(470): or       'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(std::basic_streambuf<_Elem,_Traits> *)'
1>        with
1>        [
1>            _Elem=char,
1>            _Traits=std::char_traits<char>
1>        ]
1>        while trying to match the argument list '(std::basic_ostream<_Elem,_Traits>, std::string)'
1>        with
1>        [
1>            _Elem=char,
1>            _Traits=std::char_traits<char>
1>        ]
1>Build log was saved at "file://c:\Users\kevin\Documents\Visual Studio 2008\Projects\opdracht2\opdracht2\Debug\BuildLog.htm"
1>opdracht2 - 3 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
 
[cpp]
#include <iostream>
#include <string>
using namespace std;

int main()
{
string naam1, naam2;
int leeftijd1, leeftijd2;

cout << "Wat is de naam van de 1e persoon?" << endl;
getline( cin, naam1 );

cout << "Wat is zijn/haar leftijd?" << endl;
cin >> leeftijd1;
cin.get();

cout << "Wat is de naam van de 2e persoon?" << endl;
getline( cin,naam2 );

cout << "Wat is zijn/haar leeftijd?" << endl;
cin >> leeftijd2;
cin.get();

cout << "Alle gegevens zijn ingevoerd!" << endl;
cout << "Hier volgt het resultaat:" << endl << endl;

cout << "De personen " << naam1 << " en " << naam2
<< " zijn samen "
<< (leeftijd1 + leeftijd2) << " jaar oud" << endl;

cout <<"Druk op Enter om het programma te beeindigen";
cin.get();
return 0;
}
[/cpp]

Je bent de string header vergeten te includen.
 
bedankt nu werkt die:D

vervelend dat die niet in het boek stond hopelijk staan er niet nog meer van die dingen in dat het niet werkt.
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan