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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:02:10+00:00 2026-05-26T19:02:10+00:00

In defining my Element class I get the following error: no matching function for

  • 0

In defining my Element class I get the following error:

no matching function for call to ‘Dict::Dict()’ word1.cpp:23:
    note: candidates are: Dict::Dict(std::string) word1.cpp:10:
    note: Dict::Dict(const Dict&)

I’m not calling anything, I’m merely letting Element inherit from Dict. What’s the problem here?

The other error is in my Word class constructor I get the following:

In constructor ‘Word::Word(std::string)’: word1.cpp:71:
    note: synthesized method ‘Element::Element()’ first required here

I’m really frustrated at this point as everything seems okay to me.

#include <iostream>
#include <vector>
#include <sstream>
#include <string.h>
#include <fstream>

using namespace std;

class Dict {
   public:
    string line;
    int wordcount;
    string word;
    vector <string> words;

    Dict(string f) {
        ifstream in(f.c_str());
        if (in) {
            while (in >> word) {
                words.push_back(word);
            }
        }
        else cout << "ERROR couldn't open file" << endl;
        in.close();
    }
};

class Element: public Dict { //Error #1 here 
    //Don't need a constructor
    public:
      virtual void complete(const Dict &d) = 0;
      //virtual void check(const Dict &d) = 0;
      //virtual void show() const = 0;
};

class Word: public Element{
    public:
      string temp;
      Word(string s){ // Error #2 here
          temp = s;
      }
      void complete(const Dict &d){cout << d.words[0];}
};

int main()
{
    Dict mark("test.txt"); //Store words of test.txt into vector
    string str = "blah"; //Going to search str against test.txt
    Word w("blah"); //Default constructor of Word would set temp = "blah"
    return 0;
}
  • 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-26T19:02:10+00:00Added an answer on May 26, 2026 at 7:02 pm

    You need to provide the constructor taking no arguments for your class Dict, if you are defining any constructor for it yourself.

    From where does the no parameter constructor for Dict get invoked?

    Word w("blah");
    

    Creates an Word object by calling Word(string s). However, Since Word is derived from Element which in turn is derived from Dict, their default constructors, which take no parameters will be called as well. And you do not have a no parameter constructor defined for Dict So the error.

    Solution:
    Either to provide a constructor for class Dict which takes no parameters yourself.

    Dict()
    {
    } 
    

    Or
    define a constructor in Element which calls one of the parameterized constructors of Dict in the Member Initializer List.

    Element():Dict("Dummystring")
    {
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having trouble defining the content-type of an element (phonenumber) whilst at the
When defining a method on a class in Python, it looks something like this:
I'm defining a datagrid's RowDetailsTemplate in the following way: RowDetailsTemplate={StaticResource defaultTemplate} where <UserControl.Resources> <DataTemplate
Consider this abstract class public abstract class Foo { public Injectable Prop {get;set;} }
Imagine the following template class (setter and getter for the member _t omitted): template<class
I am currently defining few grids as following: <Grid.RowDefinitions> <RowDefinition Height={TemplateBinding Height-Height/5}/> <RowDefinition Height={TemplateBinding
I´ve defined a class like this: function Class1(){ function Func1(){ /* Methods and vars
I'm having a bit of trouble defining a property in a PHP class I'm
I got problems with the extjs 4 class model. I want to get a
When defining sequential build steps I use the depends attribute of the target element.

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.