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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:08:59+00:00 2026-06-10T10:08:59+00:00

compiling the code below with g++ main.cpp functions.cpp -o run gives me the error

  • 0

compiling the code below with g++ main.cpp functions.cpp -o run gives me the error error: ‘vector’ does not name a type. Declaring namespace at the top of main.cpp usually works across all .cpp files for me.

main.cpp

using namespace std;

#include "functions.h"

main () {}

functions.h

#include <vector>

functions.cpp

#include "functions.h"
vector <int> x;

EDIT: I appreciate the fact all responders know what their talking about, but this normally works for me. Would the use of a makefile have any bearing on that? something else that I might be missing?

  • 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-10T10:09:01+00:00Added an answer on June 10, 2026 at 10:09 am

    Yes but in this example functions.cpp has not seen using namespace std since you only wrote that in main.cpp.


    Don’t add using namespace std to functions.h, use std:: to qualify types. Adding a using.. imposes an unnecessary burden on the user of your header.

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

Sidebar

Related Questions

When compiling the code below with gcc, I get an error: 'i' cannot appear
Commented code below are the reasons I think the code is not compiling, is
When compiling the code below with cl /c /clr /W4 the compiler says warning
I am compiling following code and getting following error. How to fix this? Thanks
How can I get rid of this error and other while compiling the below
I'm having trouble compiling the code below. It may also have logical errors, please
I am able to run the code below in terminal which is in respondPalindromes.hs
I am compiling the code below when the following erro comes up. I am
I have a code below. I can compile and run it normally in NetBeans.
I got some quite strange errors compiling code under gcc. It tells me that

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.