[C] Issues With Constructors!

Hello!

I’ve encountered a strange problem with my C/C++ Visual Studio Code project. I’ve been getting the following two errors in these two files respectively and I can’t figure out why:

hVex.h:

main.cpp:

2 Likes

Thanks for showing us your code; makes it way easier to help.

The first issue is because as it says, vex has no default constructor for the motor class(or any of their classes for that matter). The solution I have used is to make the instance variables that are vex devices a pointer of their object type. This works great for smart port devices but does not work on analog inputs via 3-wire ports (although digital in/out ports have worked when I have tried them).

The second issue is a result of using floats instead of doubles when you made your constructor. I would recommend just changing those to doubles in your constructor (replace the ‘float’ with ‘double’). If you really really want to use float then sure by all means there is a way to but I never would unless trying to maintain cross-compatibility with C which is not important for vex v5 through VSCode.

TL;DR: Use pointers for vex devices when in a class. Use doubles instead of floats.