我有这个代码:
#include <iostream>
#include <string>
#include <cstring>
class Animal
{
public:
Animal(const std::string &name) : _name(name)
{
}
virtual void Print() const = 0;
virtual ~Animal() {}
protected:
std::string _name;
};
class Dog : public Animal
{
public:
Dog(const std::string &name, const std::string &dogtype) : Animal(name), _dogtype(dogtype)
{
Print();
}
void Print() const
{
std::cout << _name << " of type " << _dogtype << std::endl;
}
private:
std::string _dogtype;
};
class Cat : public Animal
{
public:
Cat(const std::string …Run Code Online (Sandbox Code Playgroud) 可能重复:
G ++ Cpp中的"未定义引用"
我有这个标题
#ifndef TEST_H_
#define TEST_H_
class TEST
{
public :
TEST();
};
#endif /* TEST_H_ */
Run Code Online (Sandbox Code Playgroud)
和这个标题
#ifndef TESTS_H_
#define TESTS_H_
#include "TEST.h"
class TESTS : public TEST
{
public :
TESTS();
};
#endif /* TESTS_H_ */
Run Code Online (Sandbox Code Playgroud)
我实现了这样的标题:
#include <iostream>
using namespace std;
#include "TEST.h"
TEST:: TEST()
{
}
int main(int argc, char **argv) {
return 0;
}
Run Code Online (Sandbox Code Playgroud)
还有这个:
#include "TESTS.h"
TESTS :: TESTS() : TEST()
{
}
int main(int argc, char **argv) {
return 0; …Run Code Online (Sandbox Code Playgroud)