I have been self teaching myself C++ and having a blast at it too.
I have been working my own AI - an insane project relatable to moving to a country without knowing the language. Immersion has taught me a lot, and having a a major goal with hundreds of micro goals has fueled me forward.
BUT... I find myself with a LOT of questions. I am hoping a few of these can be answered by those in this community.
C++ 2 years ago looks different (IMO) than it does now. I have come up for air and to learn new principles and concepts and am finding that core code I learned seems to be different.
#define pragma once
is an example.
Is this new? Or did I completely miss this...
My Next curiosity:
Header Files: Is it normal, or proper practice to include classes that are shared between two other classes in a header file? For example:
#include <iostream>
using namespace std;
#ifndef __SerialPort_h__
#define __SerialPort_h__
extern char* portInput;
#endif
#pragma once
#define ARDUINO_WAIT_TIME 1000
#define MAX_DATA_LENGTH 255
#include <windows.h>
#include <iostream>
class SerialPort
{
private:
HANDLE handler;
bool connected;
COMSTAT status;
DWORD errors;
public:
explicit SerialPort(const char *portName);
~SerialPort();
// int readSerialPort(const char *buffer, unsigned int buf_size);
bool writeSerialPort(const char *buffer, unsigned int buf_size);
bool isConnected();
void closeSerial();
};
The above class "SerialPort" is defined within 'SerialPort.h' (not the famous one everyone uses) and I am trying to discern if this is standard practice, or has the author of this code lost his way?
Which is the universal, best practice for the following code. And I know answers are out there regarding this, but so many websites now have mixed information:
Cout
cplusplus.com describes cout standards to be as follows:
cout << "main function\n";
Yet time and time again in others' code:
std::cout << "main function\n";
Function Declarations
Last Year, the proper way to declare functions seemed to be:
void someFunction ()
{
some code
}
Now I am seeing this format all over the place.:
void someFunction::someFunction()
{
some code
}
So my aim is to grasp enough code to get a job programming. But I cannot move in a positive direction towards that aim without have a firm grasp on standardization, and I have tried reading the iso books, but the time I grasp every concept in those I will be 4 years older and 3 new iso documents will have been published.
A Trusted Resource?
So is there a trusted resource that is held in high esteem within the C++ community for deriving reliable, industry applicable, and standardized definitions that can be applied in modern c++ code? And if so could someone be so Kind as to point me in that direction? Specifically for PC/linux libraries.
I don't have any dev/programmer friends, and frankly its nice to have a human offer a reputable response rather than "hoping" whatever resource I find will yield promising results.
So thank you for whatever help, advice and responses you offer. I know your time is valuable.
Cheers, stay safe during this outbreak.
Andrew