Welcome, Guest. Please Login or Register
Arduino IDE for Visual Studio
 
 
When Logging a Support Issue in the Forum, please ensure you have also:-
  • Enabled vMicro > Compiler > Show Build Properties and Verbose
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
Support requests without the output above may be impossible to answer, so please help us to help you
 
  HomeSearch Tutorials & Wiki visualmicro.com LoginHelpRegister  
 
Page Index Toggle Pages: 1
Send Topic Print
How to code cpp/h files that contain a class? (Read 126 times)
Abbott HMG
Newbies
*
Offline



Posts: 6
Bedford, NY, USA
How to code cpp/h files that contain a class?
Jul 4th, 2019 at 9:39pm
 
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
Back to top
« Last Edit: Jul 4th, 2019 at 9:44pm by Visual Micro »  

HMGHelloWorld.zip (261 KB | 3 )
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10395
United Kingdom
Re: How to code cpp/h files that contain a class?
Reply #1 - Jul 4th, 2019 at 9:47pm
 
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++):
#include <Wire.h>
#include "HMGHelloWorld.h"

void HMGHelloWorld::Init()
{

} 

Back to top
 
WWW  
IP Logged
 
Page Index Toggle Pages: 1
Send Topic Print