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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:42:20+00:00 2026-06-11T12:42:20+00:00

I have a problem with some concepts of OOP class, lets say i have

  • 0

I have a problem with some concepts of OOP class, lets say i have the following classes:

  • Parser class which includes data for parsing an stream data
  • String class that include string operations for parse the stream data
  • Integer class that include integer operations for parse the stream data

So String and Integer class inherit the Parser class since they both need specific info regarding the stream like the position, the length, etc.

Now the problem comes when i have an function that uses both String and Integer functions.

Lets put this new function in a class called MultipleOperations. MultipleOperations needs the String and Integer class so it inherit both but String and Integer class already inherit Parser, so when trying to access some data from Parser class is ambiguous.

In the other hand if set String and Integer class has a composition of MultipleOperations then i wont have access to Parser class.

Also i don’t understand much the concept of “has a” since in most cases i need to reference data from the base class, so that makes it a “is a”.

Here is an example of my problem:

class Parser{
private:
    int errorcode;
    char comment;
    const char* address;
    const char* maxaddress;
    unsigned int position;
public:
    Parser(const char* _address, const char* _maxaddress) : errorcode(NO_ERROR_PRESENT) {};
    const char* s_address(const char* _address) {address = _address;}
    const char* s_maxaddress(const char* _maxaddress) {maxaddress = _maxaddress;}
    const char* s_position(unsigned int _pos) {position = _pos;}
    char r_comment() const {return comment;}
    const char* r_address() const {return address + position;}
    const char* r_maxaddress() const {return maxaddress;}
    unsigned int r_position() const {return position;}

    int geterror();
    void set_error(int code) {errorcode = code;}

    void set_comment(const char char_comment);
    void set_position(unsigned int position);
    void resetboundary(unsigned int address, unsigned int maxaddress);
};

class Integer: public Parser {
public:
    //Get an int token
    int GetInt();
};

class String: public Parser {
private:
    int NullByToken(char*, int, char);                          //Null a string by token
    void CleanString(std::string string);                       //Clean an string to its simple form (removing spaces, tabs, etc)
    public:
        Displacement* GetEndOfLine();                           //Get len till end of line
        Displacement* GetSimpleString();
        bool SplitByChar(const char token, SplitString* setstrings);
};

class MultiOperation: public String, public Integer {
    void* GetDataByPrefix(unsigned int Type, char token, const char* prefixcmp);
};

Function GetDataByPrefix needs access to Parser class and needs access to both String and Integer class.

  • 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-06-11T12:42:22+00:00Added an answer on June 11, 2026 at 12:42 pm

    Your problem is called the diamond problem.

    There are several solutions for this, to mention one, you may find it interesting. I suggest you to google it a bit.

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

Sidebar

Related Questions

I have a problem with understanding of some basic OOP concepts. I'll try to
I have some problem to get the utf-8 string from PHP using jQuery $.load()
I have some problem with the cursor when using JOprionPane. I set a cursor
I have some problem. Dialog.dismiss() does not work. I want to input ip, username,
I have some problem with this mongoid. It's my first time to use mongoDB,
I have some problem with MySQL Workbench in that I sometimes can't set foreign
I have some problem in my JDBC code. I am trying to connect through
I have some problem with Emit mapper when I try to save in database
I have some problem with displaying emoji icon in Android TextView First, I found
I have some problem with my code public IQueryable<PageItems> GetPageById(Guid Id) { var xml

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.