mysql guy
mysql guy

Reputation: 245

one c++ syntax question

Sorry if the question is silly. I come from java background.

In the following code, base_list is a parent class of SqlAloc, but what's the meaning of public memory?

class base_list :public memory::SqlAlloc  
{  
protected:  
  list_node *first,**last;  
  uint32_t elements;  
public:
};

Upvotes: 2

Views: 98

Answers (3)

Sarfaraz Nawaz
Sarfaraz Nawaz

Reputation: 361482

base_list is publicly deriving from SqlAlloc which is either a namespace-class, or nested-class, depending upon what memory is - which could be either a namespace or a class.

Upvotes: 0

memory is either a namespace or a class (struct). public means that all member functions and member data which were declared in SqlAlloc class(struct) as public and protected will be visible in base_list as public and protected.

Upvotes: 1

Ernest Friedman-Hill
Ernest Friedman-Hill

Reputation: 81694

Memory is probably a namespace (kind of like an outer class) in which SqlAlloc is defined.

C++ has both public and private inheritance (protected, too, actually.) public inheritance is just like Java inheritance; in private inheritance, though, code outside the derived class doesn't know about the base class. It's a way to inherit implementation without inheriting type. In Java, you can only do both.

Upvotes: 4

Related Questions