
Untitled
By: a guest on
Apr 28th, 2012 | syntax:
C++ | size: 1.42 KB | hits: 16 | expires: Never
#include "stdafx.h"
#include <iostream>
#include <malloc.h>
#include <string.h>
using namespace std;
template<class T>
class ChainNode{
friend class Chain;
private:
T data;
ChainNode<T> *link;
};
template<class T>
class Chain {
public:
Chain(){first = 0 ;}
private:
ChainNode<T> *first;//pointer to first Node
};
struct Pelates{
//au3ontas ari8mos pelatwn
ChainNode<int> *link ;//periexei tn sundesmo gia tn eisagwgh stn lista
char onomaPel[];//oi pelates se unsized array
};
int main(){
Pelates *StrPtr;//orizw enan pointer ap tn klassh pelates
//autos o pointer deixnei stn prwto kombo ts alusidas
Pelates *ptr;
char pel[40];
printf("enter code:");
gets(pel);
//xwros mnhmhs g tstruct, t onoma kai terminating null
ptr = (Pelates *)malloc( sizeof( struct Pelates)+ strlen( pel ) + 1 );
strcpy( ptr->onomaPel, pel);//ekxwrei t string st onoma pelath
return 0;
}
/* struct PERSON
{
unsigned number;
char name[]; // Unsized array
};
int main()
{
PERSON *ptr;
char who[40];
printf( "Enter name: " );
gets( who );
// Allocate space for structure, name, and terminating null
ptr = (PERSON *)malloc( sizeof( struct PERSON ) + strlen( who ) + 1 );
// Copy the string to the name member
strcpy( ptr->name, who );
}*/