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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:32:31+00:00 2026-05-26T02:32:31+00:00

I am compiling my code with g++ -g and I am getting the error

  • 0

I am compiling my code with g++ -g and I am getting the error message in the title.

The error is related to a function I have made, it’s signature being:

void addHead( Elem *&start , Elem *newStart );

and I am passing this function these two variables:

Elem * head;    
Elem * tempEl;

so that it looks like this:

addHead( *head , *tempEl );

The actual function is:

void addHead( Elem start , Elem newStart )
{
Elem listItem;

listItem = newStart;
*listItem.next = start;
start = listItem;
}

It pre-pends the second argument to the the beginning of a linked-list starting at the first argument.

I have been pulling my hair out with this one. No matter what I do I keep getting this error!

cannot convert Elem to Elem* for argument 1 to void addHead(Elem*, Elem*)

Edit: Forgot this error is in there too:

error: invalid initialization of reference of type Elem*& from expression of type Elem
  • 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-26T02:32:31+00:00Added an answer on May 26, 2026 at 2:32 am

    It’s being pretty specific: You’re passing an Elem, but it takes an Elem*. In particular, head is of type Elem*, but you are passing *head: of type Elem.

    Also, your definition signature doesn’t match your definition, so even when you fix the call, you will get a linker error when it can’t find addHead(Elem*, Elem*). Definitions must exactly their signatures (more correctly, declarations). Of course, neither of these changes will fix the actual implementation of addHead(), but that’s your homework 🙂

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

Sidebar

Related Questions

I have the following code and am getting this error before compiling: Fast Enumeration
guys, I have the following code, but I'm getting error at compiling time... the
I am getting the following error message when compiling or attempting to run my
While compiling my code I am getting the following error. Why is throwing an
I am getting the following error when compiling my code _CGRectZero, referenced from: _CGRectZero$non_lazy_ptr
Getting this error while compiling C++ code: undefined reference to `__stack_chk_fail' Options already tried:
While compiling the c++ code using android NDK I am getting the following error:
I have a problem with some JNI code. I'm getting the following error printed
I'm getting a lot of errors compiling code using the boost libraries, mainly when
When compiling the following code: void DoSomething(int Numbers[]) { int SomeArray[] = Numbers; }

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.