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 8145903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:48:44+00:00 2026-06-06T13:48:44+00:00

I am new to c++ programming and know the basics of c++. I am

  • 0

I am new to c++ programming and know the basics of c++. I am trying to link three files, but i am unable to get the output.I am studying the book c++ cookbook right now

Suppose we have the files a.hpp a.cpp, b.hpp b.cpp,c.hpp c.cpp with the following code:

a.hpp

#ifndef A_HPP_INCLUDED
#define A_HPP_INCLUDED
void a();
#endif

a.cpp

#include "a.hpp"
#include <iostream>
void a()
{
    std::cout<<"a \n ";
}

b.hpp

#ifndef B_HPP_INCLUDED
#define B_HPP_INCLUDED
void b();
#endif

b.cpp

#include "b.hpp"
#include <iostream>
void b()
{
    std::cout<<"b \n ";
}

c.hpp

#ifndef C_HPP_INCLUDED
#define C_HPP_INCLUDED
void c();
#endif

c.cpp

#include "a.hpp"
#include "b.hpp"
#include "c.hpp"
void c()
{
    a();
    b();

}

int main()
{
    c();
    return 0;
}

I have created all the files in one folder and commands i used to compile and link them are

$:g++ -c -Wall a.cpp b.cpp c.cpp
$:g++ -o -Wall a.o b.o c.o
$:./a.out

I was expecting the outout

a
b

but there was no output at all.Request you all to help me out with this.

  • 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-06T13:48:47+00:00Added an answer on June 6, 2026 at 1:48 pm

    Remove the -o from your g++ command line.

    You are currently telling g++ to link your objects together to a file called -Wall. So the alternative solution would be to call ./-Wall instead of ./a.out.

    Due to the spaces in your strings (" \n " vs. "\n"), you’ll still not be getting the exact expected output. Also you will probably want to replace:

    std::cout << "something \n";
    

    with

    std::cout << "something" << std::endl;
    

    if you want to have the data on screen immediately (flushing). See also C++: “std::endl” vs “\n”.

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

Sidebar

Related Questions

I'm still relatively new to Perl Programming, but I know how Perl 5 OO
I'm new to programming with accelerometers on Android. I want to know how fast
I'm pretty new to programming for Linux environments, so I don't exactly know what
I'm new to PHP programming and I wanted to know that is it possible
Hi i am new to android programming and i would like to know how
I'm new to IOS programming, I don't know how to judge the swinging direction
I'm new to iOS programming. I want to know how a database is created
Before I start know this: I am extremely new to Java and programming. How
I'm new to object oriented programming and flash. As far as I know, global
I've started learning coding for the android, I know the basics of programming in

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.