I am writing a menu driven program and I want to use classes to display the different sections of the program. The problem that I am encountering is when I am writing the header for the class my private members are giving an error that says incomplete type not allowed. Is this because its return type is void? should I be using a string type instead? The class members will only be using cout statements. Also would it be better to just use a function instead of a class?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#pragma once
#include <string>
#include <iostream>
usingnamespace std;
class study {
private:
void secOne;
void secTwo;
void secThree;
public:
void getSecOne();
void getSecTwo();
void getSecThree();
};
The class members will only be using cout statements. Also would it be better to just use a function instead of a class?
Yes. The main purpose of a class is to have some member data, and member functions that deal with that data. If the your output data via std::cout is always the same, there is no need for a class.
However, if you are going to have std::strings which change, then you could have a class, but use better names for the variables and functions:
Thank you so much TheIdeasMan for the information. I am new to this and my class is accelerated so I am having trouble keeping up. I updated my program using your input and everything is good unfortunately my professor wants me to continue using namespace std because it is an introductory class but I will keep that in mind for the future. also I did not even see the tutorials section thank you for pointing that out to me I will make that my first stop when I have questions from now on