Skip to content

Instantly share code, notes, and snippets.

@loneshark99
Created December 24, 2022 03:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save loneshark99/e6698625161b178f39e6be10a31f341b to your computer and use it in GitHub Desktop.
Save loneshark99/e6698625161b178f39e6be10a31f341b to your computer and use it in GitHub Desktop.
C++ Member Initializer List
#include "Vector3.hpp"
#include <iostream>
using namespace std;
int main()
{
Vector3 test;
cout << "X=" << test.x << " Y=" << test.y << " Z=" << test.z << endl;
}
#include "Vector3.hpp"
Vector3::Vector3() : x(1.0f), y(2.0f), z(3.0f)
{
}
#ifndef VECTOR3_HPP
#define VECTOR3_HPP
class Vector3
{
public:
float x,y,z;
Vector3();
};
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment