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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:09:49+00:00 2026-05-26T15:09:49+00:00

Currently I’m learning C++ in my book and they had an exercise on using

  • 0

Currently I’m learning C++ in my book and they had an exercise on using a previously created class called IntList and implement it using IntListProxy. My book only talks about proxies in a very simple example so I’m having a hard time with the syntax of it. What am I doing wrong with this proxy and how can I fix it? Keep in mind IntList is already a .o and I’m not allowed to include IntList.cpp when I compile this.
The error:

IntListProxy.cpp: In member function ‘bool IntListProxy::isEmpty()’:
IntListProxy.cpp:7: error: invalid use of incomplete type ‘struct IntList’
IntListProxy.h:5: error: forward declaration of ‘struct IntList’
IntListProxy.cpp: In member function ‘IntListProxy* IntListProxy::prepend(int)’:
IntListProxy.cpp:13: error: invalid use of incomplete type ‘struct IntList’
IntListProxy.h:5: error: forward declaration of ‘struct IntList’
IntListProxy.cpp: In member function ‘int IntListProxy::head()’:
IntListProxy.cpp:19: error: invalid use of incomplete type ‘struct IntList’
IntListProxy.h:5: error: forward declaration of ‘struct IntList’
IntListProxy.cpp: In member function ‘IntListProxy* IntListProxy::tail()’:
IntListProxy.cpp:25: error: invalid use of incomplete type ‘struct IntList’
IntListProxy.h:5: error: forward declaration of ‘struct IntList’
IntListProxy.cpp: In member function ‘std::string IntListProxy::toString()’:
IntListProxy.cpp:31: error: invalid use of incomplete type ‘struct IntList’
IntListProxy.h:5: error: forward declaration of ‘struct IntList’
IntListProxy.cpp: In member function ‘int IntListProxy::length()’:
IntListProxy.cpp:37: error: invalid use of incomplete type ‘struct IntList’
IntListProxy.h:5: error: forward declaration of ‘struct IntList’
IntListProxy.cpp: In member function ‘IntListProxy*       `IntListProxy::append(IntListProxy*)’:`
IntListProxy.cpp:43: error: invalid use of incomplete type ‘struct IntList’
IntListProxy.h:5: error: forward declaration of ‘struct IntList’
IntListProxy.cpp: In member function ‘int IntListProxy::operator[](int)’:
IntListProxy.cpp:49: error: invalid use of incomplete type ‘struct IntList’
IntListProxy.h:5: error: forward declaration of ‘struct IntList’
IntListProxy.cpp:51: error: expected unqualified-id before ‘}’ token
IntListProxy.cpp:51: error: expected ‘;’ before ‘}’ token

IntListProxy.h

#include <iostream>
#include <string>

using namespace std;
class IntList;

class IntListProxy
{
 public:
  IntListProxy();
  bool isEmpty();
  IntListProxy *prepend(int n);
  int head();
  IntListProxy *tail();
  string toString();
  int length();
  IntListProxy *append(IntListProxy *lst);
  int operator[](int n);
 private:
  IntList *ptr;

};

IntListProxy.cpp

#include "IntListProxy.h"

IntListProxy::IntListProxy(){}

bool IntListProxy::isEmpty(){

  ptr->isEmpty();

}

IntListProxy *IntListProxy::prepend(int n){

  return ptr->prepend(n);

}

int IntListProxy::head(){

  return ptr->head();

}

IntListProxy *IntListProxy::tail(){

  return ptr->tail();

}

string IntListProxy::toString(){

  return ptr->toString();

}

int IntListProxy::length(){

  return ptr->length();

}

IntListProxy *IntListProxy::append(IntListProxy *lst){

  return ptr->append(lst);

}

int IntListProxy::operator[](int n){

  return ptr->operator[](n);

}

Thank you in advance!

  • 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-26T15:09:50+00:00Added an answer on May 26, 2026 at 3:09 pm

    Suggested Solution:
    You need to include the header file which defines class IntList in your cpp file IntListProxy.cpp.

    Explanation:
    When instead of including the header file you add the line:

    class IntList;
    

    It Forward declares the class IntList which means for compiler it is an Incomplete type. With Incomplete types, One cannot create objects of it or do anything which needs the compiler to know the layout of IntList or more than the fact that IntList is just an type. i.e: The compiler does not know what are its members and what its memory layout is.
    But Since pointers to all objects need just the same memory allocation, You can use the forward declaration when just reffering to an Incomplete type as a pointer.

    In this case your cpp file IntListProxy.cpp needs to know the layout(members) of IntList to be able to dereference it and hence the error.

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

Sidebar

Related Questions

Currently, I am developing a product that does fairly intensive calculations using MS SQL
Currently, I have: <html> <div class=yes1><span><img src=img></span></div> </html> <script> var x = ='yes1' var
Currently I am adding object by creating it like: type TRecord = class private
Currently i'm having trouble using two functions in my -(void)viewDidLoad , both of these
Currently, my MVC 3 app has a dependency on a static class that is
Currently I am using Amazon Cloudfront to service static objects on my ASP.Net MVC3
Currently, I use an abstract factory to allow the specification of a custom class
Currently using Oracle/BEA/Plumtree ALUI Portal 6.1, and am trying to display a client's IP
Currently I am writing a program for an introductory Java class. I have two
Currently the msbuild logs for team build are appalling as they are just plain

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.