I was coding something as a little practice and I kept getting this error:
error: redefinition of a "LabMouse::LabMouse(std::__cxx::string,int)
It's saying that it was already defined in my .h
file, which it is. I'm just confused on why it's saying that I'm trying to redefine it within my .cpp
file?
The .cpp
file
#include <iostream>
#include "LabMouse.h"
LabMouse::LabMouse(const std::string aname, const int aage){
}
void LabMouse::speak(){
std::cout << "Narf!" << std::endl;
}
LabMouse::~LabMouse(){
std::cout << "LabMouse Destructor" << std::endl;
}
void LabMouse::setName(std::string name){
name = "Pinky";
}
void LabMouse::sayHello(){
std::cout << "LabMouse Name: " << aname << " ,age: " << aage << std::endl;
}
The .h
file
#ifndef LABMOUSE_H
#define LABMOUSE_H
#include <string>
class LabMouse{
private:
std::string aname = "";
int aage = 1;
public:
LabMouse(const std::string aname, const int aage){
}
void speak();
void setName(std::string aname);
void sayHello();
virtual ~LabMouse();
};
#endif