#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
class Bot_warrior
{
public:
Bot_warrior():height(78), weight(190), weapon("MiniGun"), bullets(400)
{};
int height;
int weight;
string weapon;
int bullets;
};
class Human_opponent
{
public:
Human_opponent(int height = 78, int weight = 195): height(height), weight(weight),weapon("PluseGun"),(1000)
{};
int height;
int weight;
string weapon;
int bullets;
};
int main()
{
Bot_warrior bot;
Human_opponent human;
cout << setw(10);
cout << "Stats for the human: " << endl;
cout << "Height (inches): " << human.height << endl;
cout << "Weight (lbs): " << human.weight << endl;
cout << "Weapon: " << human.weapon << endl;
cout << "Ammo: " << human.bullets << endl;
cout << endl;
cout << "Stats for the bot: " << endl;
cout << "Height (inches): " bot.height << endl;
cout << "Weight (lbs): " bot.weight << endl;
cout << "Weapon: " << bot.weapon << endl;
cout << "Ammo: " << bot.bullets << endl;
cout << endl;
return 0;
}
1>------ Build started: Project: code2, Configuration: Debug Win32 ------
1>Compiling...
1>code2.cpp
1>c:\users\martin\documents\testprogramsc++\code2\code2\code2.cpp(23) : error C2351: obsolete C++ constructor initialization syntax
1>c:\users\martin\documents\testprogramsc++\code2\code2\code2.cpp(49) : error C2146: syntax error : missing ';' before identifier 'bot'
1>c:\users\martin\documents\testprogramsc++\code2\code2\code2.cpp(49) : error C2563: mismatch in formal parameter list
1>c:\users\martin\documents\testprogramsc++\code2\code2\code2.cpp(49) : error C2568: '<<' : unable to resolve function overload
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(974): could be 'std::basic_ostream<_Elem,_Traits> &std::endl(std::basic_ostream<_Elem,_Traits> &)'
1> with
1> [
1> _Elem=wchar_t,
1> _Traits=std::char_traits<wchar_t>
1> ]
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(966): or 'std::basic_ostream<_Elem,_Traits> &std::endl(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(940): or 'std::basic_ostream<_Elem,_Traits> &std::endl(std::basic_ostream<_Elem,_Traits> &)'
1>c:\users\martin\documents\testprogramsc++\code2\code2\code2.cpp(50) : error C2146: syntax error : missing ';' before identifier 'bot'
1>c:\users\martin\documents\testprogramsc++\code2\code2\code2.cpp(50) : error C2563: mismatch in formal parameter list
1>c:\users\martin\documents\testprogramsc++\code2\code2\code2.cpp(50) : error C2568: '<<' : unable to resolve function overload
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(974): could be 'std::basic_ostream<_Elem,_Traits> &std::endl(std::basic_ostream<_Elem,_Traits> &)'
1> with
1> [
1> _Elem=wchar_t,
1> _Traits=std::char_traits<wchar_t>
1> ]
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\ostream(966): or 'std::basic_ostream<_Elem,_Traits> &std::endl(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(940): or 'std::basic_ostream<_Elem,_Traits> &std::endl(std::basic_ostream<_Elem,_Traits> &)'
1>Build log was saved at "file://c:\Users\Martin\Documents\TestProgramsC++\code2\code2\Debug\BuildLog.htm"
1>code2 - 7 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
It would really help if you used code tags and told us what line the error was occuring on.
But anyway:
|
Human_opponent(int height = 78, int weight = 195): height(height), weight(weight),weapon("PluseGun"),(1000)
|
You're missing the "bullets" before that (1000)
1 2
|
cout << "Height (inches): " bot.height << endl;
cout << "Weight (lbs): " bot.weight << endl;
|
You're missing << before the height and weight
Last edited on
I will code tag for now on. Thank you for your time.