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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T22:26:45+00:00 2026-05-12T22:26:45+00:00

Problem fixed! Thanks a lot for the constructive suggestions! I am unable to figure

  • 0

Problem fixed! Thanks a lot for the constructive suggestions!

I am unable to figure out what is the mistake in the following code. Is there something wrong with the way I am doing includes?

// This is utils.h
#ifndef UTILS_H
#define UTILS_H

#include <iostream>
#include <fstream>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <string>
#include <algorithm>

typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef stack<int> si;
typedef queue<int> qi;

#define tr(c,i) for(typeof((c).begin()) i = (c).begin() ; i!=(c).end() ; ++i )
#define all(c) (c).begin(),(c).end()
#define cpresent(c,x) (find(all(c),x) != (c).end())

#endif

// ==============================================================
// Below is main.cpp

#include "utils.h"

int main() {
    vi v;
}

On compiling “g++ main.cpp” I get the following error message:

utils.h:13: error: expected initializer before ‘<’ token
utils.h:14: error: expected initializer before ‘<’ token
utils.h:15: error: expected initializer before ‘<’ token
utils.h:16: error: expected initializer before ‘<’ token
utils.h:17: error: expected initializer before ‘<’ token
utils.h:18: error: expected initializer before ‘<’ token
main1.cpp: In function ‘int main()’:
main1.cpp:4: error: ‘vi’ was not declared in this scope
main1.cpp:4: error: expected `;’ before ‘v’

What is wrong with this code? The utils.h used to work fine some time back when I did not have the #ifndefs in it.

  • 1 1 Answer
  • 1 View
  • 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-12T22:26:45+00:00Added an answer on May 12, 2026 at 10:26 pm

    Those types (pair, stack, queue, vector, etc.) are in the std namespace. You either need to add using namespace std; at the top of your file (generally after all of the standard library includes) or fully qualify the type names by adding std:: in front of them.

    Generally, it’s better practice to fully qualify the type names than to use using namespace to avoid potential collisions between names and to make your code cleaner. You should never use using namespace std in header files.

    (Along the lines of clean code, you should consider using better, longer names for your types; ii, vii, and vvii are atrocious type names).

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

Sidebar

Related Questions

Now, thanks to community, one problem was fixed ( Delete all elements of a
I have a container div .parent with a fixed width 500px which contains a
Important Update: See update 5 at the bottom there is no performance issue in
I need to get rid of a part of a component ( make it
We've recently upgraded our Rails application. To be extra sure everything works, I've tried
I'm having trouble getting the results I want from a Salesforce/Apex/SOQL query. I want:
I've searched among jquery selectors for some time now, but can't find any solution
I have two textviews, a listview (this is a listactivity, by the way) and
I'm new to multithreading and I'm working on parallelizing an area in my application.
I have a very simple update statement: UPDATE W SET state='thing' WHERE state NOT

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.