|
In given case operator '*' overloaded is unary dereferencing operator. In case of multiplication it will be binary operator, and you need to overload it again
e.g.
class A
{
public:
A operator *(A& multA)
{
return *this;
}
A operator *(int i)
{
return *this;
}
}; -- modified at 0:49 Friday 16th September, 2005
|
|
|
|
|
Right, thanks for reminding me.
Danny
|
|
|
|
|
to continue on what prasad said, C++ have some operator wich work different ways, depending on the number of parameters it receives.
consider :
* the global scope operator (<code>::name</code>)
* the scope resolution (<code>namespace::name</code>)
* the address of operator (<code>&variable</code>)
* the bitwise and operator (<code>bool1 & bool2</code>)
* the deferenciation operator (<code>*pointor</code>)
* the multiplication operator (<code>var1 * var2</code>)
* the function call operator (<code>funct()</code>)
* the cast operator (<code>(int)</code>)
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Hi,
I have read several articles about the advantages of managed .net code over native code, but have not found any info about advantages of native over managed code.
As a C++ programmer always has the possibility to write and integrate unmanaged/native code within .net projects, I have not found any literature about where or in which cases it becomes necessary to do this, and what advantages one gets out of it.
Can someone with more knowledge and exposure to this subject put some light on it?
Thanks in advance.
Shri
|
|
|
|
|
smch wrote:
but have not found any info about advantages of native over managed code.
Faster, doesn't require the .NET framework on the target machine, therefore potentially more portable ( depending on if you use other libraries like MFC )
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I wrote some program about the file handlings.in that program i created two .doc files named "country.doc","capital.doc" and wrote some text.
while i reading that files "country.doc " working fine.
but when i`m trying to read "capital.doc" i got error when i`m opening the file
this is program i wrote
#include <iostream >
#include <fstream>
#include <conio.h>
using namespace std;
int main()
{
ofstream file1; //declaring object for ofstream to write file
file1.open("c:/cnu/country.doc");
if(file1.eof()!=0) {exit (1);}//error checking
file1<<"\nUnited States of America\n";
file1<<"United Kingdom\n";
file1<<"South Korea\n";
file1.close();//closing writing session
file1.open("c:/cnu/capital.doc");//opening anthother file
if(file1.eof()!=0) {exit (1);}//error checking
file1<<"\nWashington\n";
file1<<"London\n";
file1<<"Seoul\n";
file1.close();//file closing from writing
const int N=80;
char line[N];
ifstream file2;//set object for ifstream class
file2.open("c:/cnu/country.doc");//openign file
if(file2.eof()!=0) {exit (1);}//error checking
cout<<"\nContents of Country file\n";
while(file2)
{
file2.getline(line,N);
cout<<line;
}
="" file2.close();="" file="" closing="" froom="" reading
=""
="" <b="">file2.open("c:/cnu/capital.doc");//opening other file to read
if(file2.eof()!=0) {cout<<"ERROR WHILE FILE OPENIG";getch();return (1);}//error checking
cout<<"\nContents of Capital file\n";
while(file2)
{
file2.getline(line,N);
cout<
|
|
|
|
|
use different objects for different files,
your code should look like this
#include <iostream>
#include <fstream>
#include <conio.h>
using namespace std;
int main()
{
ofstream file1;
file1.open("country.doc");
if(file1.eof()!=0) {exit (1);}
file1<<"\nUnited States of America\n";
file1<<"United Kingdom\n";
file1<<"South Korea\n";
file1.close();
ofstream file11;
file11.open("capital.doc");
if(file11.eof()!=0) {exit (1);}
file11<<"\nWashington\n";
file11<<"London\n";
file11<<"Seoul\n";
file11.close();
const int N=80;
char line[N];
ifstream file2;
file2.open("country.doc");
if(file2.eof()!=0) {exit (1);}
cout<<"\nContents of Country file\n";
while(file2)
{
file2.getline(line,N);
cout<<line;
}
file2.close();
ifstream file22;
file22.open("capital.doc");
if(file22.eof()!=0) {cout<<"ERROR WHILE FILE OPENIG";getch();return (1);}
cout<<"\nContents of Capital file\n";
while(file22)
{
file22.getline(line,N);
cout<<line;
}
system("pause");
file22.close();
return 0;
}
|
|
|
|
|
Thanks for the reaply
for writing i used one object for two files then why it needs two objects for reading
can you explain me why it`s need
thanks
Regards
cnu...
|
|
|
|
|
Hi,
if you want to reuse file2 to read another file, you have to reset all error flags.
This one should work:
file2.open("c:/cnu/country.doc");
while(file2)
{
...
}
file2.close();
file2.clear();
file2.open("c:/cnu/capital.doc");
while(file2)
{
...
}
file2.close();
Regards
Achim Klein
We can do no great things, only small things with great love. - Mother Theresa
|
|
|
|
|
I tried what you said and it working fine
THANKS FOR YOUR REPLAY
Regards
cnu...
|
|
|
|
|
Hello,
I am working on a project and I am stuck at one place. I have 2 applications.
1-> ActiveX Control (Developed in MFC)
2-> A Windows C++ application.(No MFC...purely Windows)
How can I use the functions defined in ActiveX into this C++ application. I tried adding the ActiveX header file in my C++ application but then I get an error of CWnd, CString etc classes of MFC not found.
Please let me know if you or any of your friends know the solution. Please email me at dubeyashok@yahoo.com
Thanks in Advance.
Ashok Dubey
Ashok
|
|
|
|
|
Hello!!!
I want to store some data in CSV format. It would be like a table.
I would want to sort a column. Also select some records on some condition.
Is there any C++ class implmented for this purpose?
I do not wnat to use any database for this.
thanks..
|
|
|
|
|
I don't know of any classes that do this, I'd think it would be not hard to write one. You'd have a vector of objects, which are a custom class representing the object that's being put in the table. You'd use std::sort with functors to set which column to sort on. Obviously, you'd simply iterate through the collection to write out your CSV, overwritting the file every time.
Personally, I'd use XML and an XSLT to do the sorting.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
IS THIS IN RELATION TO COMP125 ASSIGNMENT 2 AT MACQUAUIRE UNIVERSITY
|
|
|
|
|
No.
I have a requirement in which i am storing some data in a database. This database has just one table. I was using DAO, but now I have to make it work on 64 bit platform. I can port the code to 64 bit if I can store the data in CSV format.
Hence the query.
|
|
|
|
|
Can anybody provides me with a definition for side effects in computing perspective?
for Instance what's the meaning of this term in the following sentence:
However, in C you've always been able to call a function and ignore the return
value (that is, you can call the function for its side effects).
|
|
|
|
|
LiYS wrote:
However, in C you've always been able to call a function and ignore the returnvalue (that is, you can call the function for its side effects).
In this case, it's saying that when a C++ program returns something, you're not forced to even store that value in a variable, let alone do anything with it. The 'side effects' would be what the function does, regardless of the value that it returns. For example, if you call a function that returns the contents of a file, but don't store the contents returned, the side effect would be that the file was opened on disc and read.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hello,
We are developing a C++ SOAP client program by using MSSOAPLib. Our development environment is Windows Xp Professional, Visual Studio .NET 2003. Our program works correctly in Xin Xp (local computer). But with Windows 2000, it fails in some computers and works correctly in some other.
Our code is below, the failure point in Win2000 computer is the part where we create the ISoapConnectorPtr object (int hr = Connector.CreateInstance(__uuidof(HttpConnector));)
The CreateInstance method returns the following log:
////////// LOG ////////////////////////////////////////////////////
2005-08-14 08:48:17 - http://127.0.0.1/WebServiceBetek/Service.asmx
2005-08-14 08:48:17 - 2
2005-08-14 08:48:17 - CreateInstance Method
2005-08-14 08:48:17 - Function Return = -2147221164
2005-08-14 08:48:17 - 2.1.1
2005-08-14 08:48:17 - COM ERROR
2005-08-14 08:48:17 -
2005-08-14 08:48:17 - Invalid pointer
2005-08-14 08:48:17 - Error
2005-08-14 08:48:17 - Code = 80004003
2005-08-14 08:48:17 - Code meaning = Invalid pointer
2005-08-14 08:48:17 - Source = (null)
////////// LOG ////////////////////////////////////////////////////
So we have the invalid pointer problem (80004003). But there is no failure with WinXP computers and some other Win2000 computers. As I said above, all computers seem to have the same configuration : Microsof .NET Framework 1.1, MS SOAP Toolkit 3.0 and necessary service packs.
What can be the reason for this failure?
////////// CODE ////////////////////////////////////////////////////
#import "msxml3.dll"
using namespace MSXML2;
#import "C:\Program Files\Common Files\MSSoap\Binaries\MSSOAP1.dll" \
exclude("IStream", "ISequentialStream", "_LARGE_INTEGER", \
"_ULARGE_INTEGER", "tagSTATSTG", "_FILETIME")
using namespace MSSOAPLib;
CString strRequest;
CoInitialize(NULL);
ISoapSerializerPtr Serializer = NULL;
ISoapReaderPtr Reader = NULL;
ISoapConnectorPtr Connector = NULL;
CString strFsmsWebServiceUrl = "http://127.0.0.1/WebServiceBetek/Service.asmx";
printf("WEB SERVICE URL");
printf(strFsmsWebServiceUrl.GetBuffer());
printf("2");
// Connect to the service
int hr = Connector.CreateInstance(__uuidof(HttpConnector));
printf("\nCreateInstance Method\n");
char szErrorTemp[100];
memset(szErrorTemp,0,sizeof(szErrorTemp));
sprintf(szErrorTemp,"\tFunction Return = %d\n", hr);
printf(szErrorTemp);
printf("\n2.1.1\n");
Connector->Property["Timeout"] = "10000";
////////// CODE ////////////////////////////////////////////////////
|
|
|
|
|
try adding this in web.config file of your web service
Generally to if this is not there in web.config, web service doesn't respond call from other machine. this might be possible reason.
Otherwise i'm not seeing any reason why CreateInstance is failing
<protocols>
<add name="HttpPost"/>
<add name="HttpGet"/>
</protocols>
-- modified at 9:31 Wednesday 14th September, 2005
|
|
|
|
|
when you type a code
int a =10;
printf("%d %d %d",a++,a++,a++);
returns o/p
12 11 10
can anybody pls xplain me why this o/p comes
|
|
|
|
|
C++ don't tell in which order the parameters are passed... here your compiler passes the last parameter first, so, this is why the last a++ gives you 10.
as you can see, never make such assertion in your code, and never write such code, because it will behave different ways depending on the compiler you built your code.
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
keshava shukla wrote:
int a =10;
printf("%d %d %d",a++,a++,a++);
returns o/p
12 11 10
Funny. I tested this and what I got to print out was:
10 10 10
That would be the behavior I would expect, since those are postfix (++) operators, they should be incremented after the printf() expression. I made sure and put a
cout << a;
statement after the printf() statement, and sure enough a was 13. Are you using C, or C++. The ++ is much more unpredictable in C. As the other person that responded said, just don't do it. If you have to, make three extra values, like a1, a2, a3, and increment a and assign it to each of those values and pass those into printf.
Danny
|
|
|
|
|
thanks i think it will work
|
|
|
|
|
I am just installed Microsoft VisualStudio.Net 2003 in PC.Previously i used Visual Studio 6.0 to do c++ programs.
in vc6 i set project like this
file->New
in that dialog box i selected "win32console aplication" in projects tab and gave name to my project and click ok
and finish
In the workspace i selected fileview tab and click left hand mouse button and i selected 'add file to folder' and i give some name like "test.cpp" and click ok to type my programs
MY QUESTION IS
HOW TO DO THIS IN VISUAL STUDIO.NET 2003?
i tried same process but i am unable to do
please help me
Regards
cnu...
|
|
|
|
|
Right click on the project name and choose add/new file.
Christian Graus - Microsoft MVP - C++
|
|
|
|