Using C++ with the Create

1 reply [Last post]
lspangler
Title: NooBot
Joined: 02/25/2013
Posts:
BotPoints: 8
User offline. Last seen 10 years 11 weeks ago.

I figured the code for controlling the Create using C++ would be something like

Create createObject;
createObject.connect();

However, the constructor for the Create class is private so there is an error. I was wondering if anyone had gotten this working or knows how to do it.

EDIT:
I think I found the solution but I won't be able to test it until tomorrow. After looking at create.cpp more I found the instance() function which returns a pointer to the static create object. So to control the create I think you would do something like:

Create* createObj = Create::instance();
createObj->connect();
createObj->move(1000,100);

Beta
Beta's picture
Title: The Magnificent
Joined: 02/24/2012
Posts:
BotPoints: 266
User offline. Last seen 9 years 15 weeks ago.

This is correct usage. For more information about this pattern, see the wikipedia page on singletons.

Let me know if you have any more questions about the create c++ library. It's pretty expansive.

Braden McDorman

Developer of the KIPR Link, KISS IDE, KIPR's 2D Simulator, and CBCJVM.

Reach me at bmcdorman(cat)kipr(dog)org where (cat)=@ and (dog)=. if you need assistance of any kind.