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

  • Home
  • SEARCH
  • 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 6712703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:17:26+00:00 2026-05-26T08:17:26+00:00

So in my header i made a string: string s; The compiler freaks out

  • 0

So in my header i made a string: string s; The compiler freaks out at this. I know that string is part of iostream::std. Do I have to include it in the header instead of in the .cpp file then? If so is it bad if other files that use the header include iostream? How do I deal with that?

Edit: Also for vector since it seems I’ll be needing it a lot in my assignment.

Edit2: I remember seeing #ifndef in a lot of examples of headers and I feel like it may help with my question, but I can’t seem to find a good explanation.

  • 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-05-26T08:17:27+00:00Added an answer on May 26, 2026 at 8:17 am

    string and vector are separate from iostream, and all three are part of the std namespace. You just have to properly qualify them in your header files.

    Assignment.h

     #include <string>
     #include <vector>
     // no need to #include <iostream>
    
     struct Obj
     {
        // fully qualified with std::
        std::string s_;
    
        // same:
        std::vector<std::string> v_;
     };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

consider this translation unit: #include <map> #include <string> int main() { std::map<std::string, std::size_t> mp;
I have a c++ header file containing a class. I want to use this
I have a problem with IE7 regarding an ajax call that is made by
Hello ever one I have made a main function and two files one header
I have a view that accepts 2 string parameters and 2 date values. User
I have a char * that is actually 10 digit string. I basically take
I made an custom UITableView. Then I made a custom header for sections. It
I've made a simple http server using Twisted, which sends the Content-Type: multipart/x-mixed-replace header.
Header, footer and sidebars have fixed position. In the center a content area with
include 'header.php'; // ... some code header('Location:index.php'); exit; The above code keeps giving me

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.