Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //PovecajCharIliInt.h
- #pragma once
- class PovecajCharIliInt {
- public:
- void Povecaj(void *pvoid, int velicina);
- };
- //PovecajCharIliInt.cpp
- #include <iostream>
- #include "PovecajCharIliInt.h"
- using namespace std;
- void PovecajCharIliInt::Povecaj(void *pvoid, int velicina) {
- if (velicina == sizeof(char)) {
- char *pchar = (char *)pvoid;
- ++(*pchar);
- }
- else if (velicina == sizeof(int)) {
- int *pint = (int *)pvoid;
- ++(*pint);
- }
- }
- //MainProg.cpp
- #include <iostream>
- #include "PovecajCharIliInt.h"
- using namespace std;
- int main() {
- PovecajCharIliInt pov;
- char a = 'C'; int b = 1999;
- cout << "Pre: a = " << a << "\t" << "b = " << b << endl;
- pov.Povecaj(&a, sizeof(a));
- pov.Povecaj(&b, sizeof(b));
- cout << "Posle: a = " << a << "\t" << "b = " << b << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement