Please help me with namespace.
Here is a simplified example of what I am trying to do:
There are two static C++ libraries named lib1 and lib2.
lib1 and lib2 are similar and contain the same class names, but the corresponding lib2 classes have more functionality.
lib2 classes inherit from lib1 classes of the same name.
This is what I am trying to do with made up syntax:
lib1::classA.h
1 2 3 4
class classA
{
void fn1();
};
lib2::classA.h
1 2 3 4 5
#include <lib2::classA>
class classA: public lib2::classA
{
void fn2();
};
What is the correct syntax for specifying namespace of the lib2 library?
#ifndef A_h
#define A_h
#include <iostream>
#include "../lib1/A.h"
class A : public lib1::A //error: 'lib1' has not been declared
{
public:
virtualvoid fn();
};
#endif
C:\demo_MinGW\lib_namespace\lib2>g++ A.cpp
In file included from A.cpp:1:0:
A.h:8:18: error: 'lib1' has not been declared
class A : public lib1::A
^
A.h:8:24: error: expected '{' before 'A'
class A : public lib1::A
^
A.h:9:1: error: invalid type in declaration before '{' token
{
^
A.h:9:1: warning: extended initializer lists only available with -std=c++11 or -
std=gnu++11 [enabled by default]
A.h:10:2: error: expected primary-expression before 'public'
public:
^
A.h:10:2: error: expected '}' before 'public'
A.h:10:2: error: expected ',' or ';' before 'public'
A.h:12:1: error: expected declaration before '}' token
};
^