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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T03:56:13+00:00 2026-05-30T03:56:13+00:00

I am developing C++ on Netbeans 7.1 on Ubuntu 11.04. I was wondering if

  • 0

I am developing C++ on Netbeans 7.1 on Ubuntu 11.04. I was wondering if someone could tell me why Stack fs(5); is seen as an undefined reference to to `Stack::Stack(int)’. Why is it not seen as a class with float used for T?

#include <iostream>

using namespace std ;

template <class T>
class Stack
{
public:
    Stack(int = 10) ;
    ~Stack() { delete [] stackPtr ; }
    int method1(const T&); 
    int method2(T&) ;  
    int method3()const { return top == -1 ; }
    int method4() const { return top == size - 1 ; }
private:
    int attribute1 ;  
    int attribute2 ;
    T* stackPtr ;
} ;


using namespace std; 
int main()
{
    // This line gives the error message "undefined reference to `Stack<float>::Stack(int)'"
    Stack<float> fs(5);

    return 0;
}

Thanks,
Peter.

  • 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-30T03:56:14+00:00Added an answer on May 30, 2026 at 3:56 am

    I don’t see the actual code for Stack<float>::Stack(int) anywhere. You’ve declared it, but there’s no definition. So it doesn’t actually exist (even though you’re saying it does; the compiler often just takes your word for it), and the linker won’t be able to find it, if it even gets that far.

    You need to either define the function similarly to how you’ve defined ~Stack(), or have it elsewhere in the code the same way you’d have any other member function.

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

Sidebar

Related Questions

I am using Netbeans 6.9 on Ubuntu 11.04. I am developing a console op.and
I am developing a C++ application using NetBeans 6.9 on Ubuntu 11.04. I am
I have been developing a Java program in Netbeans/Ubuntu 12.04 using OpenJdk. I have
I am developing in C++ using NetBeans 6.9 on Ubuntu 11.04. I have declared
I am developing in C++ on NetBeans 6.9 on Ubuntu 11.04. I am making
I am developing a Java web application in Netbeans IDE 7.1.1 . The IDE
I am using Netbeans IDE (J2ME) for developing a mobile application, a dictionary which
I'm a web developer and now developing a swing application. I'm using Netbeans. Currently
I am developing an application in Netbeans, and it is using JavaDB. I can
Is NetBeans recommended for developing a GUI for a Python app? Does it 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.