Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (MAIN-NAMESPACE){
- a bunch of functions/classes I need to implement...
- (EXCEPTIONS-NAMESPACE){
- a bunch of exceptions
- }
- (POINTER-COLLECTIONS-NAMESPACE){
- Set and LinkedList classes, plus iterators
- }
- }
- template<typename T>
- std::ostream& operator<<(std::ostream& os,
- const MAIN-NAMESPACE::POINTER-COLLECTIONS-NAMESPACE::Set<T>& set)
- Set A
- Set B
- Set C
- double num
- namespace A
- {
- namespace B
- {
- class C{};
- }
- }
- void f(A::B::C*);
- namespace A
- {
- void f(int*); // try commenting
- using ::f; // these two lines
- void g()
- {
- B::C* c;
- f(c);
- }
- }
- ::operator<<( cout, myObj );
- namespace MTM {//This is the MAIN-NAMESPACE
- namespace PointerCollections {
- (ITERATORS AND PREDICATE CLASSES)
- template<typename T>
- class Set {
- public:
- /////////////////////////////////
- // Definitions
- /////////////////////////////////
- private:
- /////////////////////////////////
- // Definitions
- /////////////////////////////////
- };
- ///////////////////////////////////////////////////////////////////////////////
- // The implementation part.
- ///////////////////////////////////////////////////////////////////////////////
- }
- }
- // operator<< - the same a Set::print(std::ostream& os,
- // const BinaryPredicate<T>& predicate)
- // function called with the 'predicate' parameter omitted
- template<typename T>
- std::ostream& operator<<(std::ostream& os,
- const MTM::PointerCollections::Set<T>& set){
- set.print(os);
- return os;
- }
- namespace MTM {
- using std::ostream;
- class Schedule {
- public:
- ///////////////////
- //Definitions, including:
- ///////////////////
- void registerStation(string stationName);
- void reportRegisteredStations(std::ostream& outputStream) const;
- private: //My database
- //All the classes Set recieves are defined elsewhere
- Set<RegisteredStation> places;
- Set<BusLine> busses;
- Set<TrainLine> trains;
- double tarifForBuses;
- double tarifForTrains;
- };
- }
- Schedule s();
- s.registerStation("1");
- s.reportRegisteredStations(cout);//This invokes the error. Definition follows:
- void Schedule::reportRegisteredStations(std::ostream& outputStream) const{
- outputStream<<places;
- }
- #include <iostream>
- #include <string>
- using std::string;
- namespace MTM {//This is the MAIN-NAMESPACE
- namespace PointerCollections {
- template<typename T>
- class Set {
- };
- }
- }
- template<typename T>
- std::ostream& operator<<(std::ostream& os,
- const MTM::PointerCollections::Set<T>& set){
- return os;
- }
- namespace MTM {
- using std::ostream;
- using PointerCollections::Set;
- class Schedule {
- public:
- ///////////////////
- //Definitions, including:
- ///////////////////
- void registerStation(string stationName);
- void reportRegisteredStations(std::ostream& outputStream) const;
- private: //My database
- //All the classes Set recieves are defined elsewhere
- Set<int> places;
- Set<int> busses;
- Set<int> trains;
- double tarifForBuses;
- double tarifForTrains;
- };
- void Schedule::reportRegisteredStations(std::ostream& outputStream) const{
- outputStream<<places;
- }
- }
- int main()
- {
- MTM::Schedule s;
- s.reportRegisteredStations(std::cout);
- }
- namespace test {
- class A {};
- }
- namespace test {
- std::ostream& operator<<( std::ostream&, A const & );
- }
- namespace test2 {
- void g() {
- namespace1::class1 c1;
- namespace2::namespace3::class2 c2;
- f( c1, c2 );
- }
- }
Add Comment
Please, Sign In to add comment