Hello, and thank you for taking the time to help me! This is my first real program in C++, and I am still getting used to the differences between C and C++, so I still really don't know what I'm doing. I am working on a header file and its associated source code, and am getting two repetitive errors when I compile the source code. I get these errors for the source code for every line where there is a new function being defined. The errors are as follows:
CPU.cpp expected unqualified-id before "public"
CPU.cpp expected `,' or `;' before "public"
I have tried adding ; in multiple places, and I just can't figure out what this error is telling me. I am sure it is something very basic, but I am at a loss. Can someone help me with this?
Thank you in advance for any help you can provide!
Here are the two files:
// CPU.h
#ifndef CPU_H
#define CPU_H
using namespace std;
class CPU
{
private:
string type;
int speed;
public:
CPU();
~CPU();
string getType();
int getSpeed();
void setType(string type);
void setSpeed(int speed);
void printInfo();
};
#endif
// CPU.cpp
#include <iostream>
#include <string>
#include <cstdlib>
#include "CPU.h"
using namespace std;
CPU::CPU()
{
type = "?";
speed = 0;
}
//CPU::~CPU()
//{
// cout << "CPU with the type " << type << " and the speed " << speed << " is being destroyed." << endl;
// if (type)
// delete[] type;
// if (speed)
// delete[] speed;
//}
public string CPU::getType()
{
return type;
}
public int CPU::getSpeed()
{
return speed;
}
public void CPU::setType(string newType);
{
type = newType;
}
public void CPU::setSpeed(int newSpeed);
{
speed = newSpeed;
}
public void CPU::printInfo();
{
cout << type << "," << speed << endl;
}