|
prathuraj wrote: cant find correct document for send mail from vc++.
Why you dont use of MAPI I think it will be solve your problem(you can find a lot of articles about it on my previous reply)
|
|
|
|
|
I try to collect words like Bmw or K1200S (letters and digits)
Before i add the _istdigit it worked fine .but when i put _istdigit so it could collect
digits too it dont return me values
And in debug i have that error on CString variables (CString arrays too)
In some google search i found something about pointers .so it should have
some problem on array ?
my code:
f.e m_Query = "BmW K1200S";
oid CInfoRetrievalDlg::GetQuery()
{
CString str = m_Query;
CString sp[100];
CString word = "";
int z = 0;
for ( int i = 0 ; i < str.GetLength() ; i++)
{
if ( i == 0)
{
if ( 0 != _istalpha( str.GetAt(i) ) || 0 !=_istdigit(str.GetAt(i)) )
{
word = word + str.GetAt(i);
}
}
if ( i > 0)
{
if ( i < (str.GetLength() -1))
{
if ( 0 != _istalpha( str.GetAt(i) ) || 0 !=_istdigit(str.GetAt(i)))
{
word = word + str.GetAt(i);
}
if ( 0 == _istalpha( str.GetAt(i) ) && 0 == _istdigit(str.GetAt(i)) && (0 != _istalpha( str.GetAt(i-1) ) || 0 !=_istdigit(str.GetAt(i-1)) ))
{
QueryWords[z] = word;
word.Empty();
z = z +1;
}
}
if ( i == (str.GetLength() -1) )
{
if ( 0 != _istalpha( str.GetAt(i) ) || 0 !=_istdigit(str.GetAt(i)) )
{
word = word +str.GetAt(i);
QueryWords[z] = word;
z = z +1;
}
if ( 0 == _istalpha( str.GetAt(i) ) && 0 == _istdigit(str.GetAt(i)) && (0 != _istalpha( str.GetAt(i-1) ) || 0 !=_istdigit(str.GetAt(i-1)) ))
{
QueryWords[z] = word;
z = z +1;
}
}
}
}
m_QueryWords = z;
}
|
|
|
|
|
I am a beginner in c++ programming, and I am studying topic about c++ template these few days. I tried to implement a template that have the definition and implementation in .h and .cpp files as follow:
// tpl.h
template <class ttype="">
class tpl
{
private:
int test ;
public:
tpl() ;
int get_test() ;
} ;
// tpl.cpp
template <class ttype="">
tpl::tpl()
{
test=1 ;
}
template <class ttype="">
int tpl::get_test()
{
return test ;
}
But linker errors come out when I compiled the above codes in ms-vc++6.0. I am disturbed by this problem. Could anyone helps me? thanks a lot !
BR
Yuwen
|
|
|
|
|
|
Hi Steve, I am just reading your given article on template, I think it will help me a lot. thx!
|
|
|
|
|
|
Hi,
Your Template arguments are not clear please use pre tags.
BTW, I search the html code, you are missing template argument in the function definition
template <class tType>
tpl::tpl()
{
test=1 ;
}
use
template <class tType>
tpl<tType>::tpl()
{
test=1 ;
}
Best Regards
Raj
-- modified at 0:24 Wednesday 6th June, 2007
|
|
|
|
|
Hi Rajkumar_R, thx for your reply! I am just reading an article called How To Organize Template Source Code, I think it will help to solve my problem. BTW, could you pls tell me how to paste my codes with messages using pre tag ? thx !
|
|
|
|
|
Hi,
Iam also new to this forum,
However,
1) code can be posted in between <pre> and </pre> tag
like,
class CYourClass
{
private:
int m_iVariable;
}
2) whenever you need to use < or > symbol use < or > respectively which is available in the compose window formatting panel.
Best Regards
Raj
|
|
|
|
|
Yuwen Zhou wrote: BTW, could you pls tell me how to paste my codes with messages using pre tag ? thx !
Notice the "pre" button above the smileys?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Yuwen Zhou wrote: BTW, could you pls tell me how to paste my codes with messages using pre tag ? thx !
Notice the "pre" button above the smileys? You might also want to make use of the "Preview" button.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
thx all, I am using the pre tag and code button with the following codes, I think I can post code on board now.
<code>
template <class type>
class test
{
} ;
</code>
but why stuffs in < > still couldn't be displayed ? would you pls help me with this ? thx !
|
|
|
|
|
use the < > symbol button from "formatting" option in the compose window
|
|
|
|
|
For templates, the function definition (the body) must be in the header file. I don't remember the exact reason, but it is required by the compiler.
BTW, when you post code, use the pre or code tag.
|
|
|
|
|
Hi,
No man, its possible to define template function in cpp files.
|
|
|
|
|
Yes, but then you need to include this cpp file into the header file of the template class (which then is similar as having everythig in the header file). The compiler need a full knowledge of the class to instantiate a template type. See the link provided in the first reply.
|
|
|
|
|
No,
It can be.
I used the same example of this thread.
declaration in header file
template <class T>
class tpl
{
private:
int test ;
public:
tpl() {};
int get_test() ;
} ;
And Iam going to implement the int version of get_test in cpp file
As I need some thing special for int version only.
int tpl<int>::get_test()
{
return test ;
}
please try this and verify,
And insome other cpp file I included the header
tpl<int> tplObj;
tplObj.get_test();
That is we can implement a specific type version of template class in cpp file.
Best Regards
Raj.
|
|
|
|
|
Rajkumar_R wrote: And Iam going to implement the int version of get_test in cpp file
And that's the reason why it works for you. Now, instead of declaring this in your cpp file:
tpl<int> tplObj;
tplObj.get_test();
Try to do that:
tpl<char> tplObj;
tplObj.get_test();
So, you replace the int template parameter by a char. You'll get a linker error.
|
|
|
|
|
Hi,
Your formatting was not clear. However I guess it.
Yes, I know it is the problem of Yuwen Zhou.
But what I said, I repeat.
No man, its possible to define template function in cpp files
Does It can't be?
Best Regards
Raj
|
|
|
|
|
I found in Msdn this one
_mkdir( "\\temp") (header direct.h)
but it doesnt create me folder :/
my whole code
int rows = 10;
ofstream myfile;
CString str;
CString str2;
str.Format( _T( "%d") , rows);
str2= "\\Top "+str+" Files";
str = "Top "+str+" Files.txt";
if ( _mkdir( "\\temp") )
{
str2 = str2+str;
myfile.open (str2);
myfile << print;
myfile.close();
print = print+"\n Sas pliroforoume oti dimiourgi8ike arxeio me onoma \""+str+"\"\nsto fakelo pou exete kai ta ipolipa.\n";
}
|
|
|
|
|
The windows API CreateDirectory() or _mkdir (which uses CreateDirectory() on Windows builds)
will do it.
_mkdir returns 0 if the directory was created.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Hey guys, I have a line of code here that I am just stumped on.
All of my code for this project worked when compiled under VC++6.0 pro.
For some reason, creating of a new project and inclusion of the .cpp and .h files isn't enough to make it work on visual c++ 2005 (express).
Here is the line
magiitr = &Player1.Magi[mage1];
magiitr is defined as:
vector <Mage>::iterator magiitr;
Player1 is defined globally as:
player Player1;
It is a class of my own design.
Player1.Magi is of type std::vector<mage> player::Magi .
Player1.Magi[mage1] is an array. mage1 is an int.
So this is calling the instance of the mage class in Player1.Magi[1] assuming mage1 equates to 1.
I get a compiler error of c:\nehe\magi\magination\magination.cpp(857) : error C2679: binary '=' : no operator found which takes a right-hand operand of type 'Mage *__w64 ' (or there is no acceptable conversion)
If I remove the & and make it
magiitr = Player1.Magi[mage1];
I get the error:
c:\nehe\magi\magination\magination.cpp(857) : error C2679: binary '=' : no operator found which takes a right-hand operand of type 'Mage' (or there is no acceptable conversion)
If I rewrite it to:
*magiitr = Player1.Magi[mage1];
I do not get any compiler errors anymore, but I'm worried about segmentation faults. The code is still broken at this point to determine if this fixed it, but it's nice that I'm not getting any compiler errors.
I'd like to know why a simple change of &Player to *magiitr would change anything. magiitr=&Player sets the magiitr's value to the address of the player1.magi array.
*magiitr = Player1.Magi[mage1] sets the derefereced case of magiitr to the data stored in Player1.Magi[mage1]. I think.
The real kicker is that this worked once, but not now. Any ideas?
|
|
|
|
|
Kataric wrote: magiitr = &Player1.Magi[mage1];
Assuming an iterator is a pointer, is allowed in VC6, but that is wrong. VC2002 was the first to fix this problem.
Kataric wrote: The real kicker is that this worked once, but not now. Any ideas?
The core issue is that your code is non standard, and VC6 really sucked.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Is my solution correct?
Using *magiitr = &Player1.Magi[mage1]; instead.
How would I be able to standardize my code for this as well? I don't quite understand what you mean by standardize. C++ is C++ as far as I know, and only the complier you use would make any change to that.
Also, could you explain the difference between an iterator and a pointer in this case so I don't screw this kind of thing up again?
|
|
|
|
|
Christian Graus wrote: Assuming an iterator is a pointer, is allowed in VC6, but that is wrong. VC2002 was the first to fix this problem
I'm being a bit pedantic here, but it was always wrong to assume an iterator was a pointer. The fact that it worked on MSVC6 (or any past or future compiler) is just an impementation detail.
Steve
|
|
|
|