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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:53:07+00:00 2026-05-23T09:53:07+00:00

#ifndef DATACENTER_H_ #define DATACENTER_H_ #include <map> #include <list> #include <string> #include LiLo/SoundInfo.h #include MutexCondition.h

  • 0
#ifndef DATACENTER_H_
#define DATACENTER_H_

#include <map>
#include <list>
#include <string>

#include "LiLo/SoundInfo.h"
#include "MutexCondition.h"
#include "UserInfo.h"

using namespace std;

class DataCenter : MutexCondition{

private:

    map<long long, list<SoundInfo *> > m_soundListMap;


    void add(long long deviceId, SoundInfo* soundInfo);

public:

    DataCenter();
    virtual ~DataCenter();

    static void addSoundInfo(long long deviceId, SoundInfo *soundInfo);

};

#endif /* DATACENTER_H_ */

DataCenter.cpp file

#include "DataCenter.h"

DataCenter::DataCenter() {
    // TODO Auto-generated constructor stub

}

DataCenter::~DataCenter() {
    // TODO Auto-generated destructor stub
}

void DataCenter::addSoundInfo(long long deviceId, SoundInfo *soundInfo){
    add(deviceId, soundInfo);
}

void DataCenter::add(long long deviceId, SoundInfo *soundInfo){
    list<SoundInfo*>& info_list = m_soundListMap[55];
}

I am trying to access the function call addSoundInfo from other classes so I have set this as static. Since the m_soundListMap is not a static so I think I need another function to access to the local data structure.

Inside of the static function, I call add function to add SoundInfo to the list. However, I am getting an error in the static function and it says “Can not call member function …. without object”.

How do I fix this problem? Thanks in advance..

  • 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-23T09:53:08+00:00Added an answer on May 23, 2026 at 9:53 am

    If you want to access addSoundInfo from other classes, you need to make it public, or make those other classes friends of DataCenter. static has nothing to with access control.

    A static function is not bound to an instance of the class it belongs to, and thus can not access members of that class (it also can not call member-functions). If you really want to access members from a static function, you have to pass an instance of the class as argument the the static function explicitly.

    If you struggle with such basic concepts, you should read a good book.

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

Sidebar

Related Questions

I have the following class #ifndef Container_H #define Container_H #include <iostream> using namespace std;
//// header file #ifndef _SECTION_ #define _SECTION_ #include <map> #include Employee.h using namespace std;
#ifndef SLIST_H #define SLIST_H #include llist.h using namespace std; class slist:public llist{ public: slist();
I have this main function: #ifndef MAIN_CPP #define MAIN_CPP #include dsets.h using namespace std;
Header file is graph.h #ifndef _GRAPH_H_ #define _GRAPH_H_ #include <map> #include <vector> using namespace
#ifndef DELETE #define DELETE(var) delete var, var = NULL #endif using namespace std; class
#ifndef __TEST__ #define __TEST__ namespace std { template<typename T> class list; } template<typename T>
I have created MutexCondition class like this /*MutexCondtion.h file*/ #ifndef MUTEXCONDITION_H_ #define MUTEXCONDITION_H_ #include
I have a class called Fraction : #ifndef FRACTION_H #define FRACTION_H #include <iostream> using
FILE #1 (foo.h): #ifndef FOO_H_ #define FOO_H_ #include baseclass.h #include bar.h class Bar; 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.