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 6986753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:50:57+00:00 2026-05-27T18:50:57+00:00

I have a C++ Interface class and get the following error when trying to

  • 0

I have a C++ “Interface” class and get the following error when trying to compile:

    Undefined symbols for architecture x86_64:
      "Serializable::writeString(std::ostream&, std::string)", referenced from:
          Person::writeObject(std::ostream&) in Person.o
          Artist::writeObject(std::ostream&) in Artist.o
      "Serializable::readString(std::istream&)", referenced from:
          Person::readObject(std::istream&) in Person.o
          Artist::readObject(std::istream&) in Artist.o
      ld: symbol(s) not found for architecture x86_64

clang: error: linker command failed with exit code 1 (use -v to see invocation)

Is it possible to implement a static method in an abstract class?

My implementation looks like this.

.h File

#ifndef Ex04_Serializable_h
#define Ex04_Serializable_h

using namespace std;

class Serializable {

public:
    virtual void writeObject(ostream &out) = 0;
    virtual void readObject(istream &in) = 0;

    static void writeString(ostream &out, string str);
    static string readString(istream &in);
};

#endif

.cpp File

#include <iostream>
#include "Serializable.h"

using namespace std;

static void writeString(ostream &out, string str) {

    int length = str.length();

    // write string length first
    out.write((char*) &length, sizeof(int));

    // write string itself
    out.write((char*) str.c_str(), length);
}

static string readString(istream &in) {

    int length;
    string s;

    // read string length first
    in.read((char*) &length, sizeof(int));
    s.resize(length);

    // read string itself
    in.read((char*) s.c_str(), length);
    return s;
}
  • 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-27T18:50:58+00:00Added an answer on May 27, 2026 at 6:50 pm

    try:

    void Serializable::writeString (...) {
     // ...
    }
    

    (try it without the static, and add the class name)

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

Sidebar

Related Questions

I have following simple class: @interface Article: NSObject { NSString *title; } @property (copy,
Say I have the following Objective-C class: @interface Foo { int someNumber; NSString *someString;
I have an unordered array with instances of the following class: @interface Place :
I have an unordered array of instances of the following class: @interface Place :
Have a interface class abc { public: virtual int foo() = 0; ... }
I have an interface: public abstract class Authorizer<T> where T : RequiresAuthorization { public
Say I have my class @interface Person : NSObject { NSString *name; } I
Suppose we have: interface Foo { bool Func(int x); } class Bar: Foo {
I have an interface with several events I have base class implementing the interface
I have the interface defined as below and is implemented by a single class

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.