Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9076717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T19:10:31+00:00 2026-06-16T19:10:31+00:00

I have a set up like this file.h: #pragma once namespace a { int

  • 0

I have a set up like this

file.h:

#pragma once
namespace a {
    int home(double a, double b, ...
    class b {
        int la();
    };
}

file.cpp

#include "file.h"    
using namespace a;

int home(double a, double b, ...) {
    //function stuff
}

int b::la() {
    home(1, 2, ...)
}

And b is instantiated and used in main like this:

#include "file.h"    
b instant;
instant.la()

But I have been getting this linker error everywhere where I am using the function home:

undefined reference to `a::home(double, double, ...)'
In function a::b::la()

I am pretty sure all of the CMakelists are correctly set up and everything is included.

But when I change the file.cpp to be in the namespace:

namespace a {
    all of the same stuff
}

and it works just fine?

Any ideas why this is happening?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T19:10:32+00:00Added an answer on June 16, 2026 at 7:10 pm

    Your problem is with using namespace a; up the top of your file.cpp. This is simply pulling in all the definitions from namespace a into your code. Thus, when you define int home(double, double, ...), you aren’t providing an implementation for a::home, you’re creating another function. You then have int a::home(double, double, ...) and int home(double, double, ...).

    You either need int a::home(double, double, ...) or to wrap everything in your .cpp file that’s under namespace a in namespace a { ... }.

    Edit: Your confusion stems from what a using declaration does. It simply pulls everything in from the a namespace and allows you to use it unqualified. It does not allow you to omit the qualification in definitions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have set up a screen rc file like this: log on shelltitle apt
I have set up a NInject (using version 1.5) binding like this: Bind<ISessionFactory>().ToMethod<ISessionFactory>(ctx =>
So, I have this file that has data set up like this: Bob 5
Since GLSL doesn't have an include-file option I'm trying to add this by using
I have a XIB set up like in this screenshot: alt text http://emberapp.com/jxpx777/images/interface-builder/sizes/m.png File's
OK I have backgrounds set up like this: HTML <div id=container> <div id=content> CONTENT
I have click events set up like this: $('.dialogLink') .click(function () { dialog(this); return
I have 2 tables set up like this (irrelevant rows omitted): > product -
I have a set of NSTimeIntervals like this: NSArray *mySet = [NSArray arrayWithObjects: [NSNumber
I have a query that creates a result set like this: Rank Name 1

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.