Before logging an issue, please update to the latest release of Visual Micro from the Downloads Page.

When Logging a Support Issue in the Forum, please ensure you have also:-

  • Enabled vMicro > Compiler > Show Build Properties
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
  • Click the Reply button and attach as .txt file OR
  • Click here to Email us with the file attached, and a link to your post
Support requests without the output above may be impossible to answer, so please help us to help you
 
Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic How to code cpp/h files that contain a class? (Read 1937 times)
Abbott HMG
Junior Member
**
Offline


Posts: 59
Location: Bedford, NY, USA
Joined: May 10th, 2019
How to code cpp/h files that contain a class?
Jul 4th, 2019 at 8:39pm
Print Post  
I've created cpp/h files in a test app (HMGHelloWorld). See attached zip.
When I compile it I get a redefinition of HMGHelloWorld error. I been trying for a while to work around this but to no avail. Any suggestions?

Abbott
« Last Edit: Jul 4th, 2019 at 8:44pm by Tim@Visual Micro »  

Please Register or Login to the Forum to see File Attachments
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12166
Location: United Kingdom
Joined: Apr 10th, 2010
Re: How to code cpp/h files that contain a class?
Reply #1 - Jul 4th, 2019 at 8:47pm
Print Post  
Hi,

This forum can only really cater for Visual Micro questions. You will find more experienced coders on stackoverflow and the arduino.cc forum.

One thing I could see in your code is that you redefine your class in the cpp. It is in both .h and .cpp

The cpp should define the class members a little like this.

Code (C++)
Select All
#include <Wire.h>
#include "HMGHelloWorld.h"

void HMGHelloWorld::Init()
{

} 

  
Back to top
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint