473,395 Members | 1,948 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

a problem relate to namespace and using

Hello, I want to know whether the following program is legal. the
g++-4.1 can not compile it

$ g++ -c bug2.cpp
bug2.cpp:8: error: expected unqualified-id before '}' token
bug2.cpp:15: error: 'A' is already declared in this scope
bug2.cpp:20: error: prototype for 'void n1::B::foo(const
n1::n2::A&)' does not match any in class 'n1::B'
bug2.cpp:6: error: candidate is: void n1::B::foo(const n1::A&)
$

// begin bug2.cpp
// #include "b.hpp"
namespace n1 {
class A;
class B {
void foo(const A&);
}
}

// #include "a.hpp"
namespace n1 {
namespace n2 {
class A {};
}
using n2::A;
}

// b.cpp
namespace n1 {
void B::foo(const A&) {
return;
}
}
// end

Jun 21 '06 #1
1 1208
Li Daobing wrote:
Hello, I want to know whether the following program is legal. the
g++-4.1 can not compile it

$ g++ -c bug2.cpp
bug2.cpp:8: error: expected unqualified-id before '}' token
bug2.cpp:15: error: 'A' is already declared in this scope
bug2.cpp:20: error: prototype for 'void n1::B::foo(const
n1::n2::A&)' does not match any in class 'n1::B'
bug2.cpp:6: error: candidate is: void n1::B::foo(const n1::A&)
$

// begin bug2.cpp
// #include "b.hpp"
namespace n1 {
class A;
declaration of n1::A.
class B {
void foo(const A&);
}
}

// #include "a.hpp"
namespace n1 {
namespace n2 {
class A {};
}
using n2::A;


using declaration of n1::A. This clashes with the n1::A declaration
above, since the two declarations refer to different classes (n1::A and
n1::n2::A).

Tom
Jun 21 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: NotGiven | last post by:
Please help me understand the big picture of allowing users to upload pictures and keep them separate and tied to their record in the database. I want the whole thing automated and I'm just...
1
by: Navin | last post by:
Ado Sort -Relate, Compute By, or Sort operations cannot be done on column(s) whose key length is unknown or exceeds 10 KB. hi, guys i have asp application running on iis 5.0 windows 2000 i use...
8
by: Petter Reinholdtsen | last post by:
I ran into a problem on HP-UX 11.00 the other day, where it refused to compile a program using 'using namespace std;' at the top. The reason seem to be that the compiler refuses to accept 'using...
2
by: puzzlecracker | last post by:
after reading some of the post I found out something rather radical to my previous understanding: that when you do #include<iostream> #include<string> #include<vector> etc compiler puts...
3
by: John | last post by:
(Hope I can ask this clearly...) I have three tables: tblPayments, tblCompanies, and tblPeople. tblPayments contains a field called lngPayeeID that needs to relate to records from tblCompanies...
2
by: doar123 | last post by:
Hello, I'm using a shape query, but instead of using a simple clause "RELATE field1 to field2" (relates the parent to the child), i wan't to use 2 relates. somthing like "RELATE field1 to field2...
3
by: J-T | last post by:
Hello All, I have two objects one is Product and the otherone is the Category. Category object is like Food,books,Medicine and etc which has different tax rates . My product object has...
1
by: keithb | last post by:
How can I relate data in the bound columns of a GridView control to an unbound checkbox in a template column in the same row? The checkboxes indicate which rows are to be deleted when an update...
2
by: samuel123 | last post by:
Dear All, Greetings! I have problem that how to relate between two table in phpmyadmin. Say I have two tables, project -------
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.