new classes .h .cpp Xcode, translate from Visual Studio

Good morning, I am very beginners student of openFrameworks. I'm following a tutorial trying to create a new class with openFrameworks but I cannot compile it in the right way. This because the tutorial I found in on Visual Studio and i'm working on a Mac with Xcode. This problem is blocking me and I cannot go on with the course. Can someone help me translate the code to create a new class from Visual Studio to Xcode? The language is the same, but the programme in this case is slightly different.

On Visual Studio the files are Class.H and Class.Cpp

THIS IS CLASS.H VISUAL STUDIO

#pragma once

#include "ofMain.h"

class ball {

public: ball();

void setup (ofVec2f initialPos, ofVec2f initialVel, float rad);
void update ();
void draw();

ofVec2f pos;
ofVec2f vel;
ofVec2f radius;

};

CLASS.CPP VISUAL STUDIO

#include "ball.h"

ball :: ball();{

}

void ball :: setup(ofVec2f initialPos, ofVec2f initialVel, float rad); {

ofVec2f initialPos;
ofVec2f initialVel;
float rad;

}

//-------------------------------------------------------------- void ball::update()

{ pos += vel;

if ((pos.x > ofGetWidth ()) || (pos.x < 0)){
    
    vel.x *= -1;

}

if ((pos.y > ofGetWidth ()) || (pos.y < 0)){
    
    vel.y *= -1;

}

//-------------------------------------------------------------- void ball::draw(){

ofDrawCircle (pos.x, pos.y, radius);

}

On Xcode it is slightly different and I don't know how to translate it. Here is the setting for the two XCode pages CLASS.H and CLASS.M

CLASS.H

// // Default Classes.h // default classes // // Created by Valerie Tameu on 23/08/23. //

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@interface Default_Classes : NSObject

@end

NS_ASSUME_NONNULL_END

and CLASS.m

// // Default Classes.m // default classes // // Created by Valerie Tameu on 23/08/23. //

#import "Default Classes.h"

@implementation Default_Classes

@end

Somebody can help me to traslate the code of Visual Studio here in XCode?

Thank you for the help!

Replies

What is the tutorial you are following?

I have not used openFrameworks, but your Visual Studio example has a C++ file, the .cpp file, and your Xcode file has an Objective-C file, the .m file. You either need a C++ file or an Objective-C++ file (extension .mm) to get the code to work, as I doubt openFrameworks supports Objective-C.

Have you gone through the openFrameworks Xcode setup tutorial?

https://openframeworks.cc/setup/xcode/

You will have a better chance of getting an answer at the openFrameworks forums since I doubt very few people here use openFrameworks. I never heard of it until I read your question.

https://forum.openframeworks.cc