|
I would guess VC6 because of the amount of online help you can get, but VC6 is really crappy, VC7 is tons better if you can get it.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
is that same Visual Studio.net and VC++ 7.0
Regards
cnu...
|
|
|
|
|
Yes, .NET 2002 is VC 7.0. There is also 2003 and soon, 2005.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Christian Graus wrote:
VC7 is tons better if you can get it.
Make it VC 7.1, and download it for free here[^].
My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.
|
|
|
|
|
Why the compiler complains about "'operator <<' is ambiguous" in statement like cout << I;. Is it ambiguous because it doesn't know which "<<" operator to call: the one in iostream and the one in code snippet below? If so I don't see any ambiguous exist!
#include <iostream>
#include <sstream>
#include <cstring>
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;
}
istringstream& operator>>(istringstream& is, IntArray& ia)
{
for(int j = 0; j < ia.sz; j++)
is >> ia.i[j];
return is;
}
int main()
{
stringstream input("47 34 56 92 103");
IntArray I;
input >> I;
I[4] = -1;
cout << I;
}
|
|
|
|
|
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...
|
|
|
|
|
Thanks mcnu
But actually the original implementation isn't wrong, later I found when I made the definition of friend operator "<<" inside the class the codes compile smoothly!
I wonder why the compiler treated the operator "<<" definition outside class as another function!
|
|
|
|
|
Your Welcome
But it`s must be not giving error if it`s definition made inside the class or outside the class it must be work.
In my compiler it doesn`t giving error to the "<<"
operator definition
it is only giving error to the ">>" operator definition only
my compiler is Borland C++5.0
Regards
cnu...
|
|
|
|
|
|
I read your reference and i wonder why it is needing forward declaration.
anyway thanks to you because i got some new knowledge from you
Regards
cnu...
|
|
|
|
|
At first glance, this is an issue with Koenig lookup ( read my article ). VC6 is not very standards compliant. VC7 and onwards is a whole new world.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hello everyone!
OK, I'm trying to port a C++ program that works under Borland's compiler over to Linux, using G++. When I try to compile it, I get a bunch of errors, most of them being based on this one:
'string' does not name a type
I've tried things like including string.h on all of my files and removing the .h extension, nothing worked. Then I thought that maybe string.h wasn't there for some reason, so I installed the libg++ RPM, that didn't work either... Today, I tried it on G++ for Windows, and guess what, I GOT THE EXACT SAME ERRORS! I tried the command-line parameter "IC:\MinGW\Include" to add that dir as an include directory, nope. Tried using Borland's include dir, nope. I asked Jesus to fix it for me, nope. (Just kidding...)
Anyone know what I can do next? Thanks!
Sulfurik K. Nosferathus (Darth_Sulfur)
www.SulfurMidis.com
www.SulfurSoft.tk
http://www.BeepXtreme.tk
[ftp://][http://][hotline://]tsfc.ath.cx
|
|
|
|
|
|
YAAAAAAY! It worked!
It compiled, but... how do I make an executable? I did this:
g++ -o tfc tfc.cpp
Like I do on Windows, and it generates a file called "tfc", like I specified. But how do I make it executable? I've tried that chmod 755 thing, but it still won't work... None of the tutorials on Google actually tell you how to do it... Could you? Thanks!
Sulfurik K. Nosferathus (Darth_Sulfur)
www.SulfurMidis.com
www.SulfurSoft.tk
http://www.BeepXtreme.tk
[ftp://][http://][hotline://]tsfc.ath.cx
|
|
|
|
|
|
|
i need lex and Yacc files for parsing c++ source code so that it can scan and tell no of classes ,no of functions, no of variables, etc .
So that C K Metric suite can be implemented.
basically i need lex and Yacc files for scanner and parser of C++ source code .
please help me in this regard.
|
|
|
|
|
Hello,
i has a problem, i would like all files of my home directory to list recursive, in a Array or Collection.
Which function do I need?
Could you please help me???
thanks Benjamin N.
|
|
|
|
|
Use Directory::GetFiles
-Atul, Sky Software http://www.ssware.com
Shell MegaPack For ActiveX & .Net - Windows Explorer Like Shell UI Controls
|
|
|
|
|
Thanks,
but I would to prog it self.
Someone can give me an example, please?!?
|
|
|
|
|
Hello, found a solution.
using System;
using System.IO;
using System.Collections;
namespace sharpsite
{
///
/// Zusammenfassungsbeschreibung für DirSearcher.
///
public class DirSearcher {
private string fSourceDirectory = String.Empty;
private string fExtensions = String.Empty;
public ArrayList Files = new ArrayList;
public string SourceDirectory {
get { return fSourceDirectory; }
set { fSourceDirectory = value; }
}
public string Extensions {
get {
if (fExtensions == String.Empty)
fExtensions = "*.*";
return fExtensions;
}
set { fExtensions = value; }
}
public DirSearcher() { }
public DirSearcher(string sourceDir) {
this.SourceDirectory = sourceDir;
}
///
/// Sucht alle Dateien mit den gegebenen Erweiterungen aus dem angegebenen Verzeichnis
///
/// <param name="baseDir" />Suchverzeichnis
private void FindFiles(DirectoryInfo baseDir) {
try {
string[] exts;
exts = this.Extensions.Split(';');
//Dateien suchen
foreach (string ext in exts) {
foreach (FileInfo theFile in baseDir.GetFiles(ext)) {
Files.Add(theFile);
}
}
}
catch { return; }
}
///
/// Durchsucht alle Verzeichnisse rekursiv und ruft FindFiles für jedes Verzeichnis auf
///
/// <param name="baseDir" />Basisverzeichnis
private void FindAllFiles(DirectoryInfo baseDir) {
try {
FindFiles(baseDir);
//Verzeichnisse rekursiv durchsuchen
foreach (DirectoryInfo subDir in baseDir.GetDirectories()) {
FindAllFiles(subDir);
}
}
catch { return; }
}
///
/// Die eigentliche Suchroutine - Aufruf aus dem Hauptprogramm
///
/// <param name="searchSubDirectories" />Unterverzeichnisse durchsuchen?
public void SearchFiles(bool searchSubDirectories) {
this.Files.Clear();
DirectoryInfo di = new DirectoryInfo(SourceDirectory);
if (searchSubDirectories)
FindAllFiles(di);
else
FindFiles(di);
}
}
}
|
|
|
|
|
please, somebody could publish a simple example on SNMP in C++?
Thanks!
Sorry for my english
|
|
|
|
|
Hi there.
I am desperately needing a library that can provide me with basic matrix arithmetic.
I am using a MFC VC++7.1 project for which I want the matrix functionality.
I Need:
>> To multiply matrices
>> Calculate determinant of a matrix.
>> Calculate inverse of a matrix.
>> Calculate transpose of a matrix.
I cannot find a library that is plain straight forward to use with VC++7.1 MFC project.
Please refer me to a library that will work for me???
Thanks!!!
|
|
|
|
|
Any library that you find with google is almost certainly in use by the authors. You could try reading the support forums to see if lots of other people use it and have trouble, then just choose one and bit the bullet to take the time to learn how to use it.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|