Home Redefinition error at compile time
Reply: 0

Redefinition error at compile time

user1021 Published in April 25, 2018, 12:41 am

I've been searching through other forums and questions but I can't seem to find an answer that relates to my issue. I keep getting this error that says "Redefinition of 'Shape'" in the .cpp file and it comes up for both constructors and functions.


#ifndef SHAPE_H
#define SHAPE_H

#include <iostream>
using namespace std;

class Shape {
    string name;
    Shape(string name);
    string getName() const;
    friend ostream& operator << (ostream& output, const Shape & shape);

#endif // SHAPE_H


#include <iostream>
#include "Shape.h"
using namespace std;

Shape::Shape() {
    this->name = "Shape";

Shape::Shape(string name) {
    this->name = name;

string Shape::getName() const {
    return name;

ostream& operator << (ostream& output, const Shape & shape) {
    output << shape.getName();
    return output;
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.30217 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO