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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:26:20+00:00 2026-05-23T04:26:20+00:00

This problem arose when trying to compile a sample program from Stroustrup’s Programming Principles

  • 0

This problem arose when trying to compile a sample program from Stroustrup’s Programming Principles and Practice using C++. I’m on chapter 12, where he begins using FLTK. I’m getting compiler errors in the graphics and GUI support code. Specifically Graph.h line 140 and 141:

error: invalid use of template-name 'Vector' without an argument list  
error: ISO C++ forbids declaration of 'parameter' with no type  


template<class T> class Vector_ref {  
    vector<T*> v;  
    vector<T*> owned;  
public:  
    Vector_ref() {}  
    Vector_ref(T& a) { push_back(a); }  
    Vector_ref(T& a, T& b);  
    Vector_ref(T& a, T& b, T& c);  
    Vector_ref(T* a, T* b = 0, T* c = 0, T* d = 0)  
    {  
        if (a) push_back(a);  
        if (b) push_back(b);  
        if (c) push_back(c);  
        if (d) push_back(d);  
    }  

    ~Vector_ref() { for (int i=0; i<owned.size(); ++i) delete owned[i]; }  

    void push_back(T& s) { v.push_back(&s); }  
    void push_back(T* p) { v.push_back(p); owned.push_back(p); }  

    T& operator[](int i) { return *v[i]; }  
    const T& operator[](int i) const { return *v[i]; }  

    int size() const { return v.size(); }  

private:    // prevent copying  
    Vector_ref(const Vector&);  <--- Line 140!
    Vector_ref& operator=(const vector&);  
};  

The complete headers and related graphics support code can be found here:
http://www.stroustrup.com/Programming/Graphics/

In addition to a code fix, could someone please shed some light on what is going on here in plain English. I’ve only just begun studying templates, so I have some vague idea, but it’s still out of reach. Thanks a million,

  • 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-23T04:26:21+00:00Added an answer on May 23, 2026 at 4:26 am
    Vector_ref(const Vector&);  <--- Line 140!
    

    The parameter type should be Vector_ref, not Vector. There is a typo.

    Vector_ref& operator=(const vector&);  
    

    And here the parameter should be vector<T>. You forgot to mention the type argument.

    But reading the comment, I believe its a typo as well. You didn’t mean vector<T> either. You mean these:

    // prevent copying  
    Vector_ref(const Vector_ref&);  
    Vector_ref& operator=(const Vector_ref&); 
    

    In C++0x, you can do the following to prevent copying:

    // prevent copying  
    Vector_ref(const Vector_ref&) = delete;            //disable copy ctor
    Vector_ref& operator=(const Vector_ref&) = delete; //disable copy assignment
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This problem involved me not knowing enough of C++. I am trying to access
This problem pertains to Java By using RandomAccessFile I intend to be able to
Consider this problem: I have a program which should fetch (let's say) 100 records
Ok, so this problem recently arose and I don't know why it is happening;
Edit: This problem only occurs on windows 7 and vista from what I've heard.
I have seen this problem arise in many different circumstances and would like to
This problem crops up every now and then at work. Our build machine can
This problem occurred during daylight saving time change. After the change occurred, we've noticed
This problem has been solved thanks to your suggestions. See the bottom for details.
This problem has been kicking my butt for a few days now. I have

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.