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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T16:38:11+00:00 2026-06-08T16:38:11+00:00

I’m having trouble understanding this compiler error. I wrote class(*)() in the post title

  • 0

I’m having trouble understanding this compiler error. I wrote class(*)() in the post title because the class I am instantiating is called “opaque”, but that name is not informative or relevant. It is a templatized Circular Buffer and some tests. I am using the opaque class to test the data structure with full class/struct types. I am also testing with primitives (int at the moment) and that test function does not give me this compiler error. There is more code than this, but I’ve provided what I think are the relevant sections.
The full code is here if you are interested.

gcc error:

tests.cpp: In function ‘bool opaque_fill_test(int)’:
tests.cpp:97:23: error: no matching function for call to ‘CircBuf<opaque>::remove(opaque (*)())’

tests.cpp:

struct opaque {
  int id;
  opaque(int n): id(n) {} 
  opaque operator=(const opaque &o) { this->id = o.id; }
};

opaque rcv();
CircBuf<opaque> c(size);
for (int i=0; i<size; i++) {
    if ( c.remove(&rcv)) {
        if (rcv.id != i ) {
            cout << "wrong value: " << rcv << " "
            << "should be: " << i << endl;
            return false;
        }
    } else {
        cout << "remove fail at i=" << rcv << endl;
        return false;
    }
}

CircBuf.h:

template<typename T> class CircBuf {
    ...
    template<typename T> bool CircBuf<T>::remove(T *t) {
       ...
       *t = data[front];
       ...

if i declare an opaque* and pass that to remove instead:

opaque rcv();
opaque* p = &rcv;
for (int i=0; i<size; i++) {
  if ( c.remove(p)) {
    ...
    ...

i get a similar error:

tests.cpp: In function ‘bool opaque_fill_test(int)’:
tests.cpp:96:16: error: cannot convert ‘opaque (*)()’ to ‘opaque*’ in initialization
  • 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-08T16:38:12+00:00Added an answer on June 8, 2026 at 4:38 pm

    If you have the declaration foo x();, the expression &x will actually be a function pointer assignable to something like foo *(y)(). The p variable in your last example isn’t such a function pointer, but simply a pointer to an opaque struct. Thus you cannot assign the function pointer to that variable.

    [edit]
    Just remembered: maybe you meant to declare an opaque variable and initialize it using the default constructor. Leave out the parentheses then. It’s a left-over syntax from C. You can only use the parentheses there if you actually put values in between to call a different constructor.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I am doing a simple coin flipping experiment for class that involves flipping a
We're building an app, our first using Rails 3, and we're having to build
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

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.