WCM - Das österreichische Computer Magazin Forenübersicht
 

Zurück   WCM Forum > Rat & Tat > Programmierung

Programmierung Rat & Tat für Programmierer

Microsoft KARRIERECAMPUS

 
 
Themen-Optionen Ansicht
Alt 25.04.2006, 10:20   #4
Biri
Hero
 
Registriert seit: 04.09.2001
Beiträge: 894


Standard

hi,

c++ is bei mir schon länger her, geht aber noch so halbwegs.
btw. der code hat zwar wenig sinn, aber das prinzip sollte dadurch klar sein:

Main.cpp:

PHP-Code:
#include "stdafx.h"
#include "stdafx.h"
#include <iostream>
#include <stack>
#include "TRStack.h"


int _tmain(int argc_TCHARargv[])
{
    
TRStackpExample = new TRStack(5); 
    
TRStackpExample2 = new TRStack(7);

    
bool empty = pExample->TRempty();

    
TRStack pResult = *pExample + *pExample2;
    
cout << pResult.testval;

    return 
0;

TRStack.h:

PHP-Code:
#pragma once
#include<iostream>
#include<stack>

using namespace std;

class 
TRStack
{
public:
    
// Varialbes
    
stack<doubleExample;
    
int testval;

    
// functions
    
TRStack(int n);    
    
bool TRempty(void);
    
TRStackoperator+(const TRStackr);
public:
    ~
TRStack(void);
}; 
TRStack.cpp:

PHP-Code:
#include "StdAfx.h"
#include "TRStack.h"
#include<iostream>
#include<stack>

using namespace std;

TRStack::TRStack(int n)
{
    
cout << "Stack initialisiert" << endl;
    
testval n;
}

TRStackTRStack::operator+ (const TRStackr

    
// do overloading as you like 
    // example
    
this->testval += r.testval;
    
    return *
this


bool TRStack::TRempty(void)
{
    return 
false;
}

TRStack::~TRStack(void)
{

blöde formatierung - es heißt natürlich, ohne Leerzeichen:

TRStack & TRStack :: operator + (const TRStack& r)

fg
hannes
Biri ist offline   Mit Zitat antworten
 


Aktive Benutzer in diesem Thema: 1 (Registrierte Benutzer: 0, Gäste: 1)
 

Forumregeln
Es ist Ihnen nicht erlaubt, neue Themen zu verfassen.
Es ist Ihnen nicht erlaubt, auf Beiträge zu antworten.
Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.

Gehe zu


Alle Zeitangaben in WEZ +2. Es ist jetzt 22:13 Uhr.


Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Forum SEO by Zoints
© 2009 FSL Verlag