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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:19:42+00:00 2026-06-13T08:19:42+00:00

I am getting multiple, confusing errors when building this school assignment and am hoping

  • 0

I am getting multiple, confusing errors when building this school assignment and am hoping for some direction on what might be the problem. I wouldn’t normally write it like this, but I put everything into one file as I try to debug this. Using Visual Studios Express 2012. I’m getting over 30 errors when I build, so I’m sure there is something fundamental that I am simply overlooking. Just a suggestion please, not looking for anyone to do my homework. Thanks

#include "stdafx.h"
#include <Windows.h>
#include <iostream>
#include "MessageDisplayClass.h"
#include "LogMessageClass.h"
#include "TimerEventArgs.h"

using namespace System;

ref class CustomTimerClass
{

private:
static bool stopFlag = false;

// create instance of TimerEventArgs
TimerEventArgs^ timerEvent;

public:
CustomTimerClass(void)
{
}
delegate void CustomTimerClass::TimerAlarmHandler(/*Object^ sender, TimerEventArgs^ args*/);
event CustomTimerClass::TimerAlarmHandler^ OnTimerAlarm;

property bool StopFlag
{
    bool get(void)
    {
        return stopFlag;
    }

    void set(bool b)
    {
        stopFlag = b;
    }
}

void run()
{
    Sleep(1000);
    raiseTimerAlarm();
}

void OnStart()
{
    // create instances of DisplayMessageClass and LogMessageClass classes
    DisplayMessageClass^ messageDisplayer = gcnew DisplayMessageClass(this);
    LogMessageClass^ messageLogger = gcnew LogMessageClass(this);

    // display and log messages concerning this event
    messageDisplayer->displayMessage(this, timerEvent);
    messageLogger->logMessage(this, timerEvent);
}

void raiseTimerAlarm()
{
    // create instance of TimerEventArgs and get time of instance creation
    timerEvent = gcnew TimerEventArgs();
    String^ eventTime = timerEvent->EventTime;

    // tie this instance of CustomTimerClass to OnTimerAlarm event and start event
    this->OnTimerAlarm += gcnew TimerAlarmHandler(this, &CustomTimerClass::OnStart);
    OnTimerAlarm();
}
};

ref class MainProgram
{
int main(array<System::String ^> ^args)
{
    CustomTimerClass^ timerClass = gcnew CustomTimerClass();
    DisplayMessageClass^ messageClass = gcnew DisplayMessageClass();
    LogMessageClass^ logerClass = gcnew LogMessageClass();
    timerClass->run();
    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-06-13T08:19:42+00:00Added an answer on June 13, 2026 at 8:19 am

    For the benefit of anyone else (other newbies): As it turns out, my suspicion that the problem lay in the fact that some of the classes were “#including” each other was the problem. Using forward declarations, combined with having to create a separate class altogether to act as a variable storage handler was the solution to my problem.

    Here are the two classes that were giving me the biggest problem, corrected to function correctly:

    /*
    CustomTimerClass.h
    */
    
    #include "StdAfx.h"
    #include "LogMessageClass.h"
    #include "MessageDisplayClass.h"
    #include "TimerEventArgs.h"
    #include "Variables.h"
    
    //ref class MessageDisplayClass;
    //ref class Variables;
    
    using namespace System;
    
    ref class CustomTimerClass
    {
    
    private:
    static bool stopFlag = false;
    
    // create instance of TimerEventArgs
    TimerEventArgs^ timerEvent;
    
    // create instance of MessageDisplayClass and LogMessageClass
    MessageDisplayClass^ messageDisplayer;
    LogMessageClass^ messageLogger;
    
    Variables^ flagVariable;
    
    public:
    CustomTimerClass(void)
    {
    }
    
    delegate void CustomTimerClass::TimerAlarmHandler();
    event CustomTimerClass::TimerAlarmHandler^ OnTimerAlarm;
    
    property bool StopFlag
    {
        bool get(void)
        {
            return stopFlag;
        }
    
        void set(bool b)
        {
            stopFlag = flagVariable->Flag;
        }
    }
    
    void run()
    {
        Sleep(1000);
        raiseTimerAlarm();
    }
    
    void OnStart()
    {
        // create instances of DisplayMessageClass and LogMessageClass classes
        messageDisplayer = gcnew MessageDisplayClass(this, flagVariable);
        messageLogger = gcnew LogMessageClass(this);
    
        // display and log messages concerning this event
        messageDisplayer->displayMessage(this, timerEvent);
        messageLogger->logMessage(this, timerEvent);
    }
    
    void raiseTimerAlarm()
    {
        // create instance of TimerEventArgs and get time of instance creation
        timerEvent = gcnew TimerEventArgs();
        String^ eventTime = timerEvent->EventTime;
    
        // tie this instance of CustomTimerClass to OnTimerAlarm event and start event
        this->OnTimerAlarm += gcnew TimerAlarmHandler(this, &CustomTimerClass::OnStart);
        OnTimerAlarm();
    }
    };
    
    /*
    MessageDisplayClass serves to display a message that 
    represents the time at which the TimerEventArgs class is 
    instantiated.  This time is returned through a function
    of TimerEventArgs class.
    */
    
    #pragma once
    
    #include "stdafx.h"
    #include <iostream>
    #include "TimerEventArgs.h"
    #include "Variables.h"
    
    using namespace System;
    
    ref class CustomTimerClass; // FORWARD DECLARATION HERE  CAN
                            // ONLY BE USED FOR REFERENCE.  CANNOT
                            // BE USED WHEN METHODS OF THE     CLASS
                            // ARE CALLED
    
    ref class MessageDisplayClass
    {
    
    private:
    CustomTimerClass^ customTimerRef;
    
    // Variables CLASS CREATED SOLELY TO ACT AS GO-BETWEEN BETWEEN
    // MessageDisplayClass and CustomTimerClass
    Variables^ variableRef;         
    
    static int counter;
    public:
    
    // constructor
    MessageDisplayClass(CustomTimerClass^ CustomTimerClassInput, Variables^ variableReference)
    {
        customTimerRef = CustomTimerClassInput;
        variableRef = gcnew Variables (CustomTimerClassInput); 
    }
    
    void displayMessage(Object^ sender, TimerEventArgs^ timer)
    {
        counter ++;
        if (counter > 0)
        {
            variableRef->Flag = true;
            Console::WriteLine("Message:  an event occured at time stamp: " + timer->EventTime);
        }
    }
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I tried to specify this generic but I am getting multiple errors: public void
I previous recieved help with a problem, getting a multiple option select form to
I keep getting errors that my functions have been defined multiple times. Of course
I am having a problem getting multiple attributes for one item. Below is my
For some reason, I'm getting multiple declarations of content within my header file even
I'm getting multiple definition link errors after conditionally compiling platform-specific code. My project is
I'm having some problems with getting multiple file upload to work. When I select
I am having difficulty getting multiple jPicker instances of the same type to display
Tested app in Instrumens for memory leak getting multiple leaks for using multiple times
I am issuing a query to elasticsearch and I am getting multiple record types.

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.