Created
June 17, 2016 06:04
-
-
Save boldijar/0c4f1a25523c4fbaf5501ce7e88e3051 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// invat_pt_scris.cpp : Defines the entry point for the console application. | |
// | |
#include <iostream> | |
#include <string> | |
#include <vector> | |
#include <assert.h> | |
template <class T> | |
class grades | |
{ | |
public: | |
// AICI | |
const T *begin() const { return g; } | |
const T *end() const { return g + size; } | |
T *begin() { return g; } | |
T *end() { return g + size; } | |
// PANA AICI | |
T g[100]; | |
int size = 0; | |
grades() :size(0) {} | |
grades operator+(T grade) { | |
grades newG(*this); | |
newG.g[newG.size] = grade; | |
newG.size++; | |
return newG; | |
} | |
int getSize() { | |
return this->size; | |
} | |
}; | |
using namespace std; | |
int main() { | |
grades<int> g; | |
g = g + 1; | |
g = g + 2; | |
for (int nr : g) | |
{ | |
cout << nr << endl; | |
} | |
cout << "SIZE: "<<g.getSize(); | |
int b; | |
cin >> b; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment