Hi, I'm quite new to c++ and i've gotten a bit stuck with my program.
It's still in the middle of being built but so far its supposed to recieve an input pass it to the hexagon class then the hexagon class is supposed to use it to print out the information.
but it keeps popping up with the error undeclared identifier plus a couple others.
code below:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
|
#include <iostream>
using namespace std;
int main()
{
int sizeInput, typeInput,option;
cout << "Would you like to draw a hexagon? \n";
cout << "1: Yes \n";
cout << "2: No \n";
cin >> option;
while(option == 1)
{
cout << "Please enter size of hexagon \n";
cin >> sizeInput;
cout << "Please choose type of hexagon \n";
cout << "1: Type 1 \n";
cout << "2: Type 2 \n";
cout << "3: Type 3 \n";
cout << "4: Type 4 \n";
cin >> typeInput;
Hexagon h1(sizeInput, typeInput);
//cout << sizeInput << typeInput << endl;
cout << "Would you like to draw a hexagon? \n";
cout << "1: Yes \n";
cout << "2: No \n";
cin >> option;
}
cin.ignore(2);
}
class Hexagon
{
private:
int size;
int type;
public:
//int getSize() {return size;}
//int getType() {return type;}
Hexagon(int sizeValue = 0, int typeValue = 0) : size(sizeValue), type(typeValue)
{
}
~Hexagon()
{
}
void calculation()
{
if(type ==1)
{
for (int rows=0; rows<size+1; rows++)
{
for (int spaces=0; spaces < (size - rows / 2); spaces++)
{
cout << " ";
}
for (int stars=0; stars<rows+1; stars++)
{
cout << "*";
}
rows++;
cout << endl;
}
}
}
void setSize(int sizeInput) {size = sizeInput; return;}
void setType(int typeInput) {type = typeInput; return;}
};
|
error message below
1>------ Build started: Project: Assignment 1, Configuration: Debug Win32 ------
1> Assignment 1.cpp
1>c:\users\hobo alan\documents\visual studio 2010\projects\assignment 1\assignment 1\assignment 1.cpp(22): error C2065: 'Hexagon' : undeclared identifier
1>c:\users\hobo alan\documents\visual studio 2010\projects\assignment 1\assignment 1\assignment 1.cpp(22): error C2146: syntax error : missing ';' before identifier 'h1'
1>c:\users\hobo alan\documents\visual studio 2010\projects\assignment 1\assignment 1\assignment 1.cpp(22): error C3861: 'h1': identifier not found
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Help would be greatly appreciated.