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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:26:43+00:00 2026-06-03T05:26:43+00:00

I have a MasterProcess which is a specialization of a general process concept and

  • 0

I have a MasterProcess which is a specialization of a general process concept and the MasterDocument class is supposed to consider several different specializations of MasterProcess in a possible generic way. I am using I am using virtual void Init() to achieve this functionality. The code is as follows:

#include <iostream>
#include <utility>
#include <string>
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <fstream>
#include <vector>
#include <functional>
#include <map>
#include <stdexcept>

using namespace std;

class BaseMasterProcess {

protected:

int processID;  
int num_of_Questions;  
double min_Threshold_Score_for_Process;  
double total_Process_Score;  
double overall_Audit_Value;
int question;
pair <int,double> answer;

//define all the variable used in any sub-class 
int question1;
int question2;
int question3;
int question4;
int question5;
double question1_Weightage;
double question2_Weightage;
double question3_Weightage;
double question4_Weightage;
double question5_Weightage;
int passing_Score;
pair <int,double> answer1_Option1;  
pair <int,double> answer1_Option2; 
pair <int,double> answer1_Option3;
pair <int,double> answer2_Option1;  
pair <int,double> answer2_Option2; 
pair <int,double> answer2_Option3;
pair <int,double> answer3_Option1;  
pair <int,double> answer3_Option2; 
pair <int,double> answer3_Option3;
pair <int,double> answer4_Option1;  
pair <int,double> answer4_Option2; 
pair <int,double> answer4_Option3;
pair <int,double> answer5_Option1;  
pair <int,double> answer5_Option2; 
pair <int,double> answer5_Option3;

public:
virtual void Init();
virtual double getQuestionWeightage(int ques) = 0;
virtual double getAnswerScore(int ques, int ans) = 0; 
int getNumQuestions()
{
    return num_of_Questions;
}
int getProcesssID()
{
    return processID;
}
double getMinThresholdScore()
{
    return min_Threshold_Score_for_Process;
}
double overallAuditValue()
{
    return overall_Audit_Value; 
}
};

class ConcreteMasterProcess1 : public BaseMasterProcess
{
public:
    Init()
    {
processID = 10; 
num_of_Questions = 3;  
passing_Score = 70;  
min_Threshold_Score_for_Process = 0.7; 
overall_Audit_Value = 0.1;

question1 = 1; 
question1_Weightage = 0.3;  
answer1_Option1 = make_pair (1,0.3); 
answer1_Option2 = make_pair (2,0.0);

question2 = 2; 
question2_Weightage = 0.3; 
answer2_Option1 = make_pair (1,0.3); 
answer2_Option2 = make_pair (2,0.0);


question3 = 3;
question3_Weightage = 0.4; 
answer3_Option1 = make_pair (1,0.4); 
answer3_Option2 = make_pair (2,0.0);
}

double getQuestionWeightage(int ques)
{
switch (ques)
{
    case 1:
        return question1_Weightage;
    case 2:
        return question2_Weightage;
    case 3:
        return question3_Weightage;
}

double getAnswerScore(int ques, int ans) 
{
    if (ques == question1 && ans == answer1_Option1.first)
        return answer1_Option1.second;
    else if (ques == question1 && ans == answer1_Option2.first)
        return answer1_Option2.second; 
    else if (ques == question2 && ans == answer2_Option1.first)
        return answer2_Option1.second;
    else if (ques == question2 && ans == answer2_Option2.first)
        return answer2_Option2.second;
    else if (ques == question3 && ans == answer3_Option1.first)
        return answer3_Option1.second;
    else 
        return answer3_Option2.second;

}   
};

class ConcreteMasterProcess2 : public BaseMasterProcess
{
    Init()
    {
processID = 11; 
num_of_Questions = 4;  
passing_Score = 70;  
min_Threshold_Score_for_Process = 0.75; 
overall_Audit_Value = 0.1;

question1 = 1; 
question1_Weightage = 0.25;  
answer1_Option1 = make_pair (1,0.25); 
answer1_Option2 = make_pair (2,0.0);

question2 = 2; 
question2_Weightage = 0.25; 
answer2_Option1 = make_pair (1,0.25); 
answer2_Option2 = make_pair (2,0.0);
answer2_Option3 = make_pair (3,0.15);

question3 = 3;
question3_Weightage = 0.25; 
answer3_Option1 = make_pair (1,0.25); 
answer3_Option2 = make_pair (2,0.0);

question4 = 4;
question4_Weightage = 0.2; 
answer4_Option1 = make_pair (1,0.2); 
answer4_Option2 = make_pair (2,0.0);

question5 = 5;
question5_Weightage = 0.2; 
answer5_Option1 = make_pair (1,0.2); 
answer5_Option2 = make_pair (2,0.0);
}

double getQuestionWeightage(int ques)
{
switch (ques)
{
    case 1:
        return question1_Weightage;
        break;
    case 2:
        return question2_Weightage;
        break;
    case 3:
        return question3_Weightage;
        break;
    case 4:
        return question4_Weightage;
        break;
}

double getAnswerScore(int ques, int ans) 
{
    if (ques == question1 && ans == answer1_Option1.first)
        return answer1_Option1.second;
    else if (ques == question1 && ans == answer1_Option2.first)
        return answer1_Option2.second; 
    else if (ques == question2 && ans == answer2_Option1.first)
        return answer2_Option1.second;
    else if (ques == question2 && ans == answer2_Option2.first)
        return answer2_Option2.second;
    else if (ques == question2 && ans == answer2_Option3.first)
        return answer2_Option3.second;
    else if (ques == question3 && ans == answer3_Option1.first)
        return answer3_Option1.second;
    else if (ques == question3 && ans == answer3_Option2.first)
        return answer3_Option2.second;
    else if (ques == question4 && ans == answer4_Option1.first)
        return answer4_Option1.second;
    else
        return answer4_Option2.second;

}   
};
class MasterDocument
{

std::vector<BaseMasterProcess*> myProcessList;
void AddProcess(BaseMasterProcess* iProcess)
{
myProcessList.push_back(iProcess);
}
void foo()
{
//myProcessList[...]->Method1(); //do something without knowing which specific concrete  class the process belongs to..
}
};

int main ()
{
MasterDocument master_doc;
cout << master_doc.myProcessList.size();

}
}

I get the following errors while compiling it.

**MD.cxx:81:11: error: ISO C++ forbids declaration of ‘Init’ with no type [-fpermissive]
MD.cxx:138:11: error: ISO C++ forbids declaration of ‘Init’ with no type [-fpermissive]
MD.cxx:138:6: error: conflicting return type specified for ‘virtual int ConcreteMasterProcess1::ConcreteMasterProcess2::Init()’
MD.cxx:57:15: error:   overriding ‘virtual void BaseMasterProcess::Init()’
MD.cxx:582:1: error: expected ‘;’ after class definition
MD.cxx:582:1: error: expected ‘}’ at end of input
MD.cxx:81:6: error: conflicting return type specified for ‘virtual int ConcreteMasterProcess1::Init()’
MD.cxx:57:15: error:   overriding ‘virtual void BaseMasterProcess::Init()’
MD.cxx: In member function ‘virtual double ConcreteMasterProcess1::getQuestionWeightage(int)’:
MD.cxx:119:2: error: a function-definition is not allowed here before ‘{’ token
MD.cxx: In member function ‘virtual double ConcreteMasterProcess1::ConcreteMasterProcess2::getQuestionWeightage(int)’:
MD.cxx:192:2: error: a function-definition is not allowed here before ‘{’ token
MD.cxx: At global scope:
MD.cxx:580:1: error: expected unqualified-id at end of input**
  • 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-03T05:26:44+00:00Added an answer on June 3, 2026 at 5:26 am

    I guess you’re trying to provide a constructor for the class ConcreteMasterProcess2. You should do it this way:

    class ConcreteMasterProcess2 : public BaseMasterProcess {
    public:
        ConcreteMasterProcess2() {
             /* ... */
        }
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have written all the code in a silverlight class library (dll) and linked this
Have a linking (or ref) table which has a dual primary key. Need to
I have a program which performs a Monte Carlo-type simulation. Currently I have written
Have anyone used Redmine Documentor which lets you convert PHP to HTML to Redmine
Have a bunch of classes which I need to do serialize and deserialize from/to
Have you ever tried working with a XAML file which contains thousand tons of
I'm working on a simple experiment in Python. I have a master process, in
Have just started using Visual Studio Professional's built-in unit testing features, which as I
Have a rails app that is supposed to display a list of products/managers. After
have next code: class GameTexture { private: LPDIRECT3DTEXTURE9 texture; unsigned char *alphaLayer; UINT width,

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.