Click here to Skip to main content
15,921,226 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
GeneralRe: why it is giving runtime error? Pin
Christian Graus11-Sep-05 15:56
protectorChristian Graus11-Sep-05 15:56 
GeneralRe: why it is giving runtime error? Pin
mcnu11-Sep-05 16:13
mcnu11-Sep-05 16:13 
GeneralRe: why it is giving runtime error? Pin
Christian Graus11-Sep-05 16:20
protectorChristian Graus11-Sep-05 16:20 
GeneralRe: why it is giving runtime error? Pin
mcnu11-Sep-05 16:50
mcnu11-Sep-05 16:50 
GeneralRe: why it is giving runtime error? Pin
Christian Graus11-Sep-05 16:51
protectorChristian Graus11-Sep-05 16:51 
GeneralRe: why it is giving runtime error? Pin
Nemanja Trifunovic12-Sep-05 2:35
Nemanja Trifunovic12-Sep-05 2:35 
Questionoperator << is ambiguous? Pin
LiYS9-Sep-05 18:24
LiYS9-Sep-05 18:24 
AnswerRe: operator << is ambiguous? Pin
mcnu10-Sep-05 2:00
mcnu10-Sep-05 2:00 
I made some modifications in your code and it is working fine. i think objective of program is" reads input from user and get printed on screen" .that works fine and you need call operator "[]" like this:

I.operator[](-1);

#include <iostream>

#include <string>

#include <conio>

using namespace std;

class IntArray

{

public:

enum { sz = 5 };

int i[sz];

IntArray() { memset(i, 0, sz* sizeof(*i)); }

int& operator[](int x)

{

return i[x];

}

friend ostream&operator<<(ostream& os, const IntArray& ia);

friend istream&operator>>(istream& is, IntArray& ia);

};


ostream& operator<<(ostream& os, const IntArray& ia)

{

for(int j = 0; j < ia.sz; j++)

{

os << ia.i[j];

if(j != ia.sz -1)

os << ", ";

}

os << endl;

return os;

}


istream& operator>>(istream& is, IntArray& ia)

{

for(int j = 0; j < ia.sz; j++)

is >> ia.i[j];

return is;

}


int main()

{

/*stringistream input; */

IntArray I;

cin >> I;

//I[4] = -1; // Use overloaded operator[]

cout << I;
return 0;

}

Regards
cnu...
GeneralRe: operator &lt;&lt; is ambiguous? Pin
LiYS10-Sep-05 2:49
LiYS10-Sep-05 2:49 
GeneralRe: operator &lt;&lt; is ambiguous? Pin
mcnu10-Sep-05 6:10
mcnu10-Sep-05 6:10 
GeneralRe: operator &lt;&lt; is ambiguous? Pin
LiYS10-Sep-05 15:06
LiYS10-Sep-05 15:06 
GeneralRe: operator &lt;&lt; is ambiguous? Pin
mcnu10-Sep-05 17:28
mcnu10-Sep-05 17:28 
GeneralRe: operator &lt;&lt; is ambiguous? Pin
Christian Graus11-Sep-05 12:35
protectorChristian Graus11-Sep-05 12:35 
Question&quot;'string' does not name a type&quot;? Pin
Lord Kixdemp9-Sep-05 11:12
Lord Kixdemp9-Sep-05 11:12 
AnswerRe: &quot;'string' does not name a type&quot;? Pin
Nemanja Trifunovic9-Sep-05 14:02
Nemanja Trifunovic9-Sep-05 14:02 
QuestionRe: &quot;'string' does not name a type&quot;? Pin
Lord Kixdemp9-Sep-05 16:42
Lord Kixdemp9-Sep-05 16:42 
AnswerRe: &quot;'string' does not name a type&quot;? Pin
Michael Dunn9-Sep-05 20:09
sitebuilderMichael Dunn9-Sep-05 20:09 
GeneralRe: &quot;'string' does not name a type&quot;? Pin
Lord Kixdemp10-Sep-05 5:50
Lord Kixdemp10-Sep-05 5:50 
QuestionC++ Metrics suite Pin
Member 21064129-Sep-05 9:38
Member 21064129-Sep-05 9:38 
QuestionList of all Files in my Directory Pin
i-p-g-i9-Sep-05 6:10
i-p-g-i9-Sep-05 6:10 
AnswerRe: List of all Files in my Directory Pin
Anonymous10-Sep-05 0:40
Anonymous10-Sep-05 0:40 
GeneralRe: List of all Files in my Directory Pin
i-p-g-i11-Sep-05 21:33
i-p-g-i11-Sep-05 21:33 
GeneralRe: List of all Files in my Directory Pin
i-p-g-i11-Sep-05 23:01
i-p-g-i11-Sep-05 23:01 
Questionsnmp Pin
sebastianos8-Sep-05 15:32
sebastianos8-Sep-05 15:32 
QuestionPLEASE HELP I NEED MATRIX LIBRARY!! Pin
BenPage8-Sep-05 8:10
BenPage8-Sep-05 8:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.