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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:57:58+00:00 2026-06-11T11:57:58+00:00

I have experience in C++ but have recently been using python exclusively at work,

  • 0

I have experience in C++ but have recently been using python exclusively at work, and I am very rusty. Each file is listed below:

main.cpp

#include "stack.h"

int main(int argc, char** argv){
    return 0;
}

stack.h

#ifndef STACK_H
#define STACK_H

#define NULL 0

template <class elementType>
class stack{

    struct node
    {
        elementType data;
        node* next;
    };

    node* top;

public:

    stack(){
        top = NULL;
    }

    ~stack(){
        node temp = top;
        while (top != NULL){
            top = top->next;
            delete temp;
        }
    }

    void push(elementType x){
        node temp = new node();
        temp.data = x;
        temp.next = top;
        top = temp;
    }

    elementType pop(){
        node temp = top;
        top = top->next;
        return temp;
    }

    bool isEmpty(){
        return top == NULL;
    }
};

#endif //STACK_H

makefile

a.out : main.o stack.o
    gcc -o a.out main.o stack.o

main.o : main.cpp stack.h 
    gcc -O -c main.cpp

stack.o : stack.h
    gcc -O -c stack.h

clean :
    rm main.o stack.o

So, when I cd in to the project directory and type make i get:

gcc -O -c main.cpp
gcc -O -c stack.h
stack.h:7:10: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘<’ token
make: *** [stack.o] Error 1

I’ve been searching around for a solution, but as far as I can tell my code is correct. I’m not looking for help with the actual stack implementation, and I realize this code won’t actually do anything with an empty main, but I can’t seem to fix this compile error.

  • 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-11T11:57:59+00:00Added an answer on June 11, 2026 at 11:57 am

    Use g++ to compile C++, not gcc. Also, you don’t need to compile a header.

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

Sidebar

Related Questions

I don't have much experience with Serial I/O, but have recently been tasked with
I have very little experience using Sharepoint but a good amount using Visual Studio
Hi I have some experience with programming but I'm not very good with pointers.
I have experience developing in android and using REST services, but now I'd like
I have recently been learning Python and am dipping my hand into building a
I've recently started using boost. So far most things have been pretty straight forward.
Im new to both ruby and rails, but have experience with java, javascript and
What does x :: xs' mean? I dont have much functional experience but IIRC
I don't have any experience with SVG but I was hoping to use this
I don't have any experience building software for Windows but I have experience with

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.