Cwapface 0 Newbie Poster

Not sure, change them to protected should work though.

yea, you're right, it does work. Unfortunately, the private members need to be private. So what should I do???

Cwapface 0 Newbie Poster

ughhh...okay, class D is now able to access class A's function (yay!), but now it doesn't seem to be able to access the private members. Why? I thought when you used friend operator, it allows access to private members..?

Cwapface 0 Newbie Poster

Thanks a lot for your help. I thought that if you included the header file in the other class, then it would inherit it (at least, thats what the professor said). Thanks again!

Cwapface 0 Newbie Poster

Okay, I cannot figure this out. I still get the same error:

Error 1 error C2039: 'function' : is not a member of 'D'

Here's what I have:

Class A.h:

#pragma once
#include <string>
using namespace std;

class D;

class A
{
    public:
		void function(string s);
		friend class D;
        
    private:
        string name;
        string email;
        
    };

Class D.h:

#pragma once
#include <vector>
#include "A.h"

class L;
class ListOfD;

class D
{
	public:
		friend class L;
		friend class ListOfD;
        
    private:
              //not important right now
};

Class L.cpp(this is where the error is):

#include "L.h"
string L::somethingnotimportant(string & command)
{
    string result;
    if(command.substr(0,4)=="some")
	{
		string parameter=command.substr(5,9999);
		D p;
    --------->   p.function(parameter);
		lop.lastID++;
		p.patronIdNumber = lop.lastID;
		lop.add(p);		
	}
	else if(command == "PRINTP")
	{
		//result = printp();
	}
    else if(command == "QUIT")
    {
        result = "Goodbye!";
    }
    else
    {
        result = "UNKNOWN COMMAND";
    }
    
    return result;
}

Okay, I think thats enough code to see the problem. I left out some information, so no one steals this code. Anyways, the function from class A is suppose to be inherited from class D, as well as the two string variables, right? Because nothing from class A can be used unless I create a new object A.