need some direction learning

I am a neo about this C++ thing, but I managed to take someone's almost complete display library and make it work. I am that dangerous. Now I am trying to adapt it to a different display. This is for a NANO to drive the display using Arduino IDE to compile. I have copied the previous .ino, .cpp, & .h files and made modifications. It is not complete, but I decided to try to compile it to see if I had any errors that didn't involve the none complete portions (the void routines).
I am getting this error:

ArgusDisplay.cpp:20:1: error: 'ArgusDisplay::ArgusDisplay(int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int)' cannot be overloaded

ArgusDisplay::ArgusDisplay

^~~~~~~~~~~~

In file included from C:\Users\Bill\AppData\Local\Temp\arduino_build_436279\sketch\ArgusDisplay.cpp:15:0:

ArgusDisplay.h:23:3: error: with 'ArgusDisplay::ArgusDisplay(int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int)'

ArgusDisplay //** the FUNCTION #s these follow are in .ino file

^~~~~~~~~~~~

and I have no idea why.

this is the original section of the .cpp file:

#include "LiquidCrystalEAX.h"

//--------------------------------------------------------------------------------
// CONSTRUCTION / DESTRUCTION.

// declare pin data type = int
LiquidCrystalEAX::LiquidCrystalEAX
(
int pinData0, //** D0 5 == D2
int pinData1, //** D1 6 == D3
int pinData2, //** D2 7 == D4
int pinData3, //** D3 8 == D5
int pinData4, //** D4 9 == D6
int pinData5, //** D5 10 == D7
int pinData6, //** D6 11 == D8
int pinData7, //** D7 12 == D9
int pinDataSelect, //** A0 13 == D10
int pinWriteEnable, //** /WR 14 == D11
int pinReadEnable, //** /RD 15 == D12
int pinLED, //** LED 16 == D13
int pinClock, //** ENB 19 == D14
int pinChipSelect, //** /CS 20 == D15
int pinReset

and this is the same section in the new file:

#include "ArgusDisplay.h";
//--------------------------------------------------------------------------------
// CONSTRUCTION / DESTRUCTION.

// declare pin data type = int
ArgusDisplay::ArgusDisplay
(
int pinData0, // CH1/CLP0 5 == D2 output
int pinData1, // CH2/CLP1 6 == D3 output
int pinData2, // CH3/CLP2 7 == D4 output
int pinData3, // CH4/CLP3 8 == D5 output
int pinData4, // CH5/CLP4 9 == D6 output
int pinData5, // CH6/CLP5 10 == D7 output
int pinData6, // Underbar/CLP6 11 == D8 output
int pinData7, // CLP7 12 == D9 output
int pinClear, // Clear# 13 == D10 output
int pinBlank, // Blank# 14 == D11 output
int pinLoad , // Load# 15 == D12 output
int pinLED , // LED 16 == D13 output
int pinStrobe, // Strobe 19 == A0 output
int pinReady, // READY 20 == A1 input
int pinBackspace, // Backspace 21 == A2 output
int pinExtra // 22 == A3
) :


is it a problem here or a problem later on causing this error?
Since it is virtually identical I can't figure it.
The .h files are also basically identical.
I have not yet figured out :: and : and the diff between () and {} and that may be part of it.

Can you point me in the right direction?
thanks

If your header looks like this:

1
2
3
4
5
// class or struct, same thing
class MyClass {
    public:
        MyClass(int, int int);
};


Then the (non-inline) implementation of the constructor should look like this:

1
2
3
4
MyClass::MyClass(int name1, int name2, int name3)
{
     // more code here
}


So, in your case, it would be something like:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
ArgusDisplay::ArgusDisplay
(
int pinData0, // CH1/CLP0 5 == D2 output
int pinData1, // CH2/CLP1 6 == D3 output
int pinData2, // CH3/CLP2 7 == D4 output
int pinData3, // CH4/CLP3 8 == D5 output
int pinData4, // CH5/CLP4 9 == D6 output
int pinData5, // CH6/CLP5 10 == D7 output
int pinData6, // Underbar/CLP6 11 == D8 output
int pinData7, // CLP7 12 == D9 output
int pinClear, // Clear# 13 == D10 output
int pinBlank, // Blank# 14 == D11 output
int pinLoad , // Load# 15 == D12 output
int pinLED , // LED 16 == D13 output
int pinStrobe, // Strobe 19 == A0 output
int pinReady, // READY 20 == A1 input
int pinBackspace, // Backspace 21 == A2 output
int pinExtra // 22 == A3
)
{
    // code here
}

Last edited on
Ganado
Thanks for the comeback
It appears that what I have is what you suggested.
This namespace and classes is totally confusing to me and I have not found a good (understandable to me) description yet. On your code, there needs to be a : after the ) on line 19. If I compile it without that it tells me there is an "initializer" missing. How is that initializing what???????

I have restarted this conversion and determined that the problem I listed was caused further down in the program. It appears that the compiler errors do not necessarily point to the actual problem. Sometimes I can fix the first problem listed and all the rest disappear. This time it was something in another file.

Anyway, I now have a file set that still compiles with all the class stuff that I do not understand. Now I need to redo the voids to make it work. That should be a lot easier. At least I think I understand that part.
The : syntax after the ( ) is called a member initializer list.
https://www.geeksforgeeks.org/when-do-we-use-initializer-list-in-c/

It might be a compiler error if you are constructing a derived class, but the base class doesn't have a default constructor. But it's hard to tell without seeing the relevant code. Or if your class has a reference that isn't initialized.

It sounds like the original issue you're having is resolved? Yes, it sounds like you have figured out that it's usually the first error reported that is the more important. The errors further down are mostly garbage; I'm not sure why C++ compilers don't just stop at the first error per compilation unit.
Last edited on
the problem I listed was caused further down in the program. It appears that the compiler errors do not necessarily point to the actual problem.
This is very true. When the compiler detects an error, the actual problem is on that line or earlier. It is never(?) further down.
Sometimes I can fix the first problem listed and all the rest disappear.
This is also pretty common. Once there's an error, it can cascade into tons of other errors. So always start with the first error listed.
thanks all
I know enough to fix code, but starting from scratch is not where I am yet. So I took this program and made it work for a display I had - it was coded for it but didn't quite work.
Now I found another display and I am modding the program to work for that. My mods messed up the classes and I was lost. I started over trying not to break the classes, so far so good.
Probably not much value in doing it except keeping my 78 yo brain active. They are very old alphanumeric displays.
Topic archived. No new replies allowed.