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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:40:08+00:00 2026-05-29T09:40:08+00:00

The compiler is not recognizing my object heatingUnit as a type of the class

  • 0

The compiler is not recognizing my object heatingUnit as a type of the class HeatingUnit. I have no idea why?

// Jimoh Ovbiagele (JAO945)

#include <iostream>
#include <stdio.h>
#include <stdbool.h>
#include "HeatingUnit.h"

class BangBangControl{

public:

  HeatingUnit *heatingUnit;
  int tempToMaintain;


BangBangControl(int temp, bool isOn, int initialTemp)
: heatingUnit(new HeatingUnit(isOn, initialTemp)),
  tempToMaintain(temp){

}

void setTemp(int newTemp){
  tempToMaintain = newTemp;
}

int getTemp(){
  return tempToMaintain;
}

int update(){
  int i = heatingUnit.tick();
  if (i > tempToMaintain + 2) heatingUnit.turnOff();
  if (i < tempToMaintain - 2) heatingUnit.turnOn();
  return i;
}

int main(){
  BangBangControl bBC(50, true, 0);

  for(int i = 0; i < 100; i++){        
    std::cout << "Temp to maintain is: " << bBC.getTemp() << " Current temp is: " << bBC.update() << "\n"; 

  }

  return(0);
}


};

I receive this error log

BangBangControl.cpp: In member function ‘int BangBangControl::update()’:
BangBangControl.cpp:31: error: request for member ‘tick’ in ‘((BangBangControl*)this)->BangBangControl::heatingUnit’, which is of non-class type ‘HeatingUnit*’
BangBangControl.cpp:32: error: request for member ‘turnOff’ in ‘((BangBangControl*)this)->BangBangControl::heatingUnit’, which is of non-class type ‘HeatingUnit*’
BangBangControl.cpp:33: error: request for member ‘turnOn’ in ‘((BangBangControl*)this)->BangBangControl::heatingUnit’, which is of non-class type ‘HeatingUnit*’

  • 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-29T09:40:10+00:00Added an answer on May 29, 2026 at 9:40 am

    You’ve got a pointer to HeatingUnit which you need to dereference when you go to apply methods on it, so your update method should be:

    int update(){
        int i = heatingUnit->tick();
        if (i > tempToMaintain + 2) heatingUnit->turnOff();
        if (i < tempToMaintain - 2) heatingUnit->turnOn();
        return i;
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am getting confused on why the compiler is not recognizing my classes. So
Why does the compiler not find the base class function signature? Changing foo( a1
In the code below, why does the compiler not complain for mClass2? class CMyClass{
Why does the C# compiler not even complain with a warning on this code?
The Visual Studio compiler does not seem to warn on signed/unsigned assignments, only on
I was wondering if there is a possible optimization where the compiler does not
Can a C++ compiler produce a not so good binary? You can think here
Compiler Error Keyword 'this' is not available in the current context delegate void CallBack(int
I am not overly competent in C++ and this compiler error is just making
I know compiler may or may not perform inline expansion of a function whether

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.