|
1. We can't see the stuff in <> because you didn't check Do not treat <'s as HTML tags
2. Why do you expect it to recognise Matrix ?
3. Why do you define STD ? The only reason I can think of is to put STD:: in front of methods, but you've put using namespace std;, which makes this redundant
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
1. Please post here instead of via email
2. Please check the box below the text entry window so that we can see the code that uses <> brackets.
3. It may help to post the actual error
4. It's obvious that you expect your includes to provide you with a matrix class. As such, posting all your code is unlikely to help, the problem is that it can't see this class, for whatever reason. Does any of these header files define a class called Matrix ? I assume the #ifdef is to differentiate between a templated and non-templated class. Are you copying this code from somewhere ? It looks like it's being written for use with crappy compilers that are no-where near standard C++. Why not just code for your compiler ?
Also, if you're including iostream.h and not iostream ( etc ), then the using namespace std stuff is useless, and if you're including iostream (etc), then you're already assuming your compiler supports namespaces.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
In the C++ STL is there a defined class/method or feature to convert/cast a structure of C-style character arrays to a structure of std::strings?
Sorry if this is in the archives but I did search before posting...
|
|
|
|
|
The string class takes a char array to it's constructor I believe. How are you wanting to do this ? There's no method to take an unknown struct and convert it to another unknown struct ( that is, from one struct the STL knows nothing about to another ).
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
My program is passed a pointer to a data-filled structure for which all elements are char arrays...I am looking for a way to change the type of the buffer or copy the buffer to so that I can use C++ features to work on the fields of the new buffer.
from C-style:
struct Carrays
{
char field1[50];
...
char field100[25];
} Carrays_t;
to C++ style:
struct Strings
{
std::string field1;
...
std::string field100;
}
|
|
|
|
|
Hi,
std::string implements basic_string& operator=(const E *s) .
So, you could add a conversion-constructor like this one:
struct Strings
{
Strings(const Carrays& ToCopy);
std::string field1;
...
std::string field100;
}
And use the assignment operator to initialize your new fields:
Strings::Strings(const Carrays& ToCopy)
{
field1 = ToCopy.field1;
...
field100 = ToCopy.field100;
}
Regards
Achim Klein
We can do no great things, only small things with great love. - Mother Theresa
|
|
|
|
|
If by structure you mean class or struct , then "no".
If by structure you mean some other structure, as a container like std::vector , then "yes", and
void TransferStrings(const wchar_t* from, size_t size, std::vector<std::wstring>& to)
{
std::copy(from, from + size, std::back_inserter(to));
} should do it.
--
The Blog: Bits and Pieces
-- modified at 5:26 Sunday 18th September, 2005
|
|
|
|
|
Hi..everyone.
Anybody can help me?????
I have problem to do my project using mfc.net. Actually i'm a student then I want to develop a project about drawing tools.So I have problem with the coding, I don't know the coding for drag and drop button.My problem situation like this I want draw a image like a car then the image will be saved in the button. If the user want to draw a car they just drag and drop the button so the car is already drawn at the screen.
Next , I want to color the car so user can choose any color that they want to use it.May I have a coding to do like that situation .Please help me, I really want a coding as soon as possible.So, if anyone can be sent me an example project for drawing tools or similar project that I was doing now.
Thank you...
allo it's me
-- modified at 5:38 Thursday 15th September, 2005
|
|
|
|
|
MFC.NET ?????
MFC is perfectly the opposite of .NET, so i doubt such a product exist !
do you mean MFC 7 instead (provided with Visual Studio .NET 2003/2005) ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
toxcct wrote:
MFC is perfectly the opposite of .NET
I wouldn't exactly say that. MFC is just a UI toolkit for C++ developers. If you read Nick Kramer's blog on blogs.msdn.com, or if you go to the PDC this year, you'll note that MFC and .NET can integrate quite well.
That said, there is no managed MFC project right now, and I don't think there will be, as I see no reason for one with the new Avalon UI, as well as the existing Windows Forms toolkit.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Cops & Robbers
Judah Himango
-- modified at 14:23 Friday 16th September, 2005
|
|
|
|
|
If you're using MFC in a .NET compiler, you have GDI+ available to you. In GDI+, you can use the DrawImage function with an Image Attributes object that can specify a colour range to make transparent. This is how you'd get an irregular bitmap and draw it onto an existing image.
GDI+ also offers matrix operations by which you can change colors in an image, you can also do flood filling, if you want.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Where I can find the GDI+ in MFC and how tu use it.
allo it's me
|
|
|
|
|
Read my articles on this site. Just search for my surname (graus), you'll find them.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
class A
{
public:
A& operator*()
{
return *this;
}
void f()
{
}
};
int main()
{
A a;
A* p = &a;
(*p).f();
}
Why the operator '*' doesn't get called, I can't even set the break point inside it!
|
|
|
|
|
overloading * operator make object of that class use that, not pointer.
Following code will make call to overloaded *
int main()
{
A p;
(*p).f();
}
|
|
|
|
|
Then what the real application of this operator?
|
|
|
|
|
As other operators. Operator overloading meant for giving more meaning to UDT's.
For example you can see any smart pointer class.
You can use object of those classes and pointer.
e.g. CComPtr<someInterface> somePtr;
somePtr->someFn();
(*somePtr).someFn();
refer http://www.codeproject.com/cpp/ismart.asp[^]
|
|
|
|
|
SO overloading operator* doesn't work on the multiply *, as in x = 2 * 3 ?
Danny
|
|
|
|
|
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;
}
|
|
|
|