1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
|
#include <cmath>
#include <iostream>
#include <limits>
using namespace std;
///first Class definition
class Dim
{
public:
Dim(int, int, int);
void setPdb();//Set the Power Delay Profiles
int get_tap_length();//returns the tap length
void setTdL_Scenario(int );//Set the TdL_Scenario
void setAntennaNum(int,int);// Set the Antenna numbers.
int getNN();//returns the NN length
int getMM();//returns the MM value
void show();
//Data Members
private:
int Pdb[];
int tap_length;
int TdL_Scenario;//input to the system
int NN; // Number of receive antennas(input to the system)
int MM; // Number of transmit antennas(input to the system)
};
//Constructor of Dim//
Dim::Dim(int m,int n, int scenario)
{
setTdL_Scenario(scenario);
setPdb();
setAntennaNum(m, n);
}
//End of Constructor
//Member function//setTdL_Scenario
void Dim::setTdL_Scenario( int scenario)
{
TdL_Scenario = scenario;
}
//End of Member function//setTdL_Scenario
//Set Power Delay Profiles
void Dim::setPdb()
{
switch(TdL_Scenario)
{
case 1:
Pdb[0] = 1;Pdb[1]=3;
tap_length =2;
break;
case 2 :
Pdb[0] =3; Pdb[1] = 6;Pdb[2] = 2;
tap_length = 3;
break;
default :
cout<< "İnvalid TDL_SCENARİO";
}
}
//End of Member function//Set Power Delay Profiles
//Member function//setAntennaNum
void Dim::setAntennaNum(int m,int n)
{
NN = n;
MM = m;
}
//End of Member function//setAntennaNum
int Dim::get_tap_length()
{
return (tap_length);
}
int Dim::getNN()
{
return (NN);
}
int Dim::getMM()
{
return (MM);
}
//New class(Second class definition)//
////////////
//My problem is that,
//I am trying to declare multiple dimensional array at the class Generateq
//(class below),with paremeters of the Class Dim such as MM,NN,Tap_Length
//like PDB[M][N][TAP_LENGTH]
////////////I am using composition such as defining Dim class at the
//Generateq class
class Generateq
{
public:
Generateq(Dim &);
private:
const int TAP_LENGTH ;//These values are my dimensional paremeters.
const int N;//////////I get these values by member initilazer at the
const int M;///////// constructor
double *PDB;// this is not what I want(one dimensional)
//double PDB[TAP_LENGTH][N][M];
//At this point Iam trying to declare multipledim array
//This sample is wrong
Dim dimension;
};
Generateq::Generateq(Dim &dimdim)
:dimension(dimdim),
TAP_LENGTH(dimdim.get_tap_length()),
N(dimdim.getNN()),//I am getting values
M(dimdim.getMM())//from previous class Dim
{
cout<<"Constructor";
PDB = new double[TAP_LENGTH];//Create 1 dimension array.
}
///Main Code///
int main()
{
Dim a(2,2,1);/// Dim class definition
Generateq generate(a);//Generateq ,class definition
std::cout <<" Press ENTER to continue...";
std::cin.ignore( std::numeric_limits<std::streamsize>::max(), '\n' );
return(0);
}
|