Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3635030
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T00:51:11+00:00 2026-05-19T00:51:11+00:00

I have observer.h , client.h and field.h files. In observer.h there is Subject class

  • 0

I have observer.h , client.h and field.h files.

In observer.h there is Subject class which has

// observer.h

class Subject  {
public:
 virtual ~Subject(){};
 Subject(){};
 virtual void Attach(Observer*);
 virtual void Detach(Observer*);
 virtual void Notify(bool _value);
 virtual bool getCheckedIn(){};
private:
 vector < Observer* >  _observers;
};

 

#ifndef CLIENT_H
#define CLIENT_H

#include "Field.h"

class Client : public Subject {
public:
 Client(string _name, Field *_field) : client_name(_name) ,field(_field) , checked_in(false) {}

 void setCheckedIn(bool _value){
  checked_in = _value;
  Notify(_value);
 }

 void enterRow(string _row_name){
  field->deneme();
  setCheckedIn(true);
 }

 bool getCheckedIn(){ return checked_in;}
private:
 bool checked_in;
 string client_name;

 Field *field;

};

#endif // CLIENT_H

 

#ifndef Field_H
#define Field_H
#include "CreateRow_absFac.h"
#include "observer_pattern.h"
#include <vector>
#include <string>
using namespace std;

// Template Class 
class Field{
public:
 Field(); 
 // Template method 
 void field_creator();
 virtual void setAbstractRow() = 0;
protected:
 FarmFactory *abstract_row1;
 FarmFactory *abstract_row2;
 FarmFactory *abstract_row3;

 Rows *row1 ;
 Rows *row2 ;
 Rows *row3 ;
 Sensor sensor1; 
};

When compiled , got this error :

ld: duplicate symbol Subject::Notify(bool) in /Users/barisatamer/Desktop/se311/PROJECT/build/PROJECT.build/Debug/PROJECT.build/Objects-normal/x86_64/Field.o and /Users/barisatamer/Desktop/se311/PROJECT/build/PROJECT.build/Debug/PROJECT.build/Objects-normal/x86_64/main.o

If I remove virtual functions it compiles without error. What is the problem with virtual functions ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T00:51:12+00:00Added an answer on May 19, 2026 at 12:51 am

    We can’t actually see it here, but the problem is probably that you defined Subject::notify(bool) in a header file (your observer.h just declares it, it doesn’t define it) and you included that header file in both Field.cpp and main.cpp, so you get multiple definitions. The fix is to move the definition into a source file so its only defined once.

    General rule — DECLARE things in header files, DEFINE them in non-header source files. Note that include guards are irrelevant here — they prevent something being declared multiple times in a single compilation unit, but what’s needed is to avoid defining something multiple times in different compilation units.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have made a generic Observer interface and an Observable class, but can't compile
I have only one class with many instances. Every instance is observer of couple
I have a Client that has a to-many-relationship to Invoice , the property is
I have been given a new task from the client which is basically creating
I have problem with reporting services rendering on the client which is performing very
I have a form for creating/editing an event. There is a Client drop down
In my Java Sockets program, I have implemented a client-server Observer pattern. That is,
I have a problem with Observer-Pattern and deadlock using threads. package observerDeadLock; import java.util.Observable;
I have a UIView subclass with an added observer for the UIKeyboardWillShowNotification and UIKeyboardWillHideNotification
I have an Observable and an Observer . The observable does download some stuff

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.