|
CORBA::Boolean CScope::Fineroot
(
IlAdapter::BaseTable*& corbaTexts,
{
corbaTexts = new IlAdapter::BaseTable;
if (result)
{
}
return result;
}
modified on Monday, January 12, 2009 8:53 AM
|
|
|
|
|
Please read Chris's "how to get someone to care enough to answer your question" rules.
One of them mentions the pre tag.
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
Giving a real answer...
We can have no idea when to delete the memory you just new ed. You're showing a member function that makes a new object for you.
The answer to your question depends on the code that calls this function. We have no idea about that.
result is not defined, and not shown where it comes from either.
I know we're clever in this forum, but we're not gods. (OK, CPallini might be)
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
Iain Clarke wrote: OK, CPallini might be
Always mocking that poor guy!
BTW: Do you know my new site, www.free.techie.god.answerz.com?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Me think it should be at least in the caller of the method CScope::Fineroot .
It depends where the data will used and how low should it life should be.
|
|
|
|
|
ptr_Electron wrote: CORBA
Ok, there is the problem . No seriously, doing memory management in CORBA is really a pain. If you don't even understand the basic concepts of memory management in C++, then you'll be in great troubles. If you really wants to understand things a bit more in details, you really have to read a book on CORBA and understand it, otherwise you'll be completely lost. And almost nobody here will be able to help you because it's too specific to your application.
Good luck...
|
|
|
|
|
If you are not going to use it outside the Fineroot function, then delete it at the end.
The actual confusion is that you are not showing us what you are gonna do with corbaTexts. If you're going to use it outside the scope of this function, delete it at the place where it will be used (and *after* it is used).
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Hi.....
I have a small problem in getting the hostname of the mapped drive.
I have mapped a shared folder of a machine in network on my system.
I have to get the name of the machine from the mapped drive.
I was not able to find any proper function for that.
Please do let me know if there is some function or some way to do it, because in my program i have to get the name of the machine.Is there a way out?
Please do help me out.
Thnx in advance...
|
|
|
|
|
raesa wrote: Please do let me know if there is some function or some way to do it, because in my program i have to get the name of the machine.Is there a way out?
Have you tried WNetGetConnection() ?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
oops
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
|
I did some digging, and the following code worked for me:
TCHAR szBuf [MAX_PATH];
DWORD dwSize = MAX_PATH;
DWORD dw = WNetGetConnection (_T("p:"), szBuf, &dwSize);
It gave me "\\myserveraddress\sharename" in szBuf.
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
|
That was one of the first results in google, but it's using .net namespace functionality, and mapping drives.
So almost the exact opposite of what he needs.
Phew, regained my sense of superiority after replying to the wrong person earlier!
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
Iain Clarke wrote: Phew, regained my sense of superiority after replying to the wrong person earlier!
You can still delete that post and hardly anyone would know.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Yeah I didnt see .net I delete previous post.
Now I changed title of my reply.
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
Hamid. wrote: I delete previous post.
No, don't join them!
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
Iain Clarke wrote: Codeproject MVP for C++, I can't believe it's for my lounge posts...
But I may have a superb reason to defy your arrogant assumptions.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Infamy, infamy, they've all got it in fo' me!
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
Hi All,
Did anyone of u ever faced any similar issue.
One of my template class funciton is overloaded...But after instantiating with a pointer, i'm not able to call the overloaded function.
ex:
template<typename Ty>
class sample
{
public:
typedef Ty& reference;
typedef Ty* pointer;
typedef const Ty* const_pointer;
typedef const Ty& const_reference;
pointer address(reference p_data_r) const
{
return &p_data_r;
}
const_pointer address(const_reference p_data_r) const
{
return &p_data_r;
}
};
int main()
{
sample<int*> sample_obj;
//Calling address with const pointer
const int* iptr=new int();
const int* &const_reference=iptr;
const int**const_pointer = sample_obj.address(const_reference);
return 0;
}
Error Message::
error C2664: 'int *sample<Ty>::address(int &) const' : cannot convert parameter 1 from 'const int *' to 'int &'
1> with
1> [
1> Ty=int *
1> ]
1> Conversion loses qualifiers
Let me know your suggestions...
Thanks alot.
Shakeel
|
|
|
|
|
Nothing to do with overloading. For both overloads, you're trying to pass a value of type const int * & through a parameter of type int * & . The compiler correctly says that it can't convert a const int * & to a int * & because int * & is less qualified.
Here's one way of altering the code so it compiles:
template<typename Ty>
class sample
{
public:
typedef Ty& reference;
typedef Ty* pointer;
typedef const Ty* const_pointer;
typedef const Ty& const_reference;
const_pointer address(const_reference p_data_r) const
{
return &p_data_r;
}
pointer address(reference p_data_r) const
{
return &p_data_r;
}
};
int main()
{
sample<int*> sample_obj;
int* iptr=new int();
int* const &const_reference=iptr;
int* const *const_pointer = sample_obj.address(const_reference);
return 0;
} The position of const within a type declaration has a significant impact on the type you end up declaring:
const int* and int const* both mean pointer to const int - i.e.you can alter the pointer, but not the int it points at.
int * const means constant pointer to integer - i.e. you cannot alter the pointer, but you can alter the int it points at.
|
|
|
|
|
That's an interesting question! The issue is that contrary to what one might expect, typedef const Ty* const_pointer does not translate to typedef const int** const_pointer when Ty is int . Instead, it translates to typedef int * const * const_pointer . Consequently, the following code does compile with VC9.
template <typename T>
class Sample
{
public:
typedef const T* const_pointer;
typedef const T& const_reference;
const_pointer address( const_reference ref ) const
{
return &ref;
}
};
int main()
{
Sample<int*> s1;
int val = 10;
int * const pval = &val;
int * const & ref = pval;
int * const * p = s1.address( ref );
return 0;
}
--
gleat
http://blogorama.nerdworks.in[ ^]
-- Number Two's eyes narrowed and became what are known in the Shouting and Killing People trade as cold slits, the idea presumably being to give your opponent the impression that you have lost your glasses or are having difficulty keeping awake. Why this is frightening is an, as yet, unresolved problem. -- HHGTG
|
|
|
|
|
When to delete ILayer is Initiated in the below case
ABC::ABC
(
CScope_i* scope
):
AsObject(scope),
itsSppAst(new ILayer::Ast(scope->cppScope().Handle()))
{
//
}
|
|
|
|
|
ptr_Electron wrote: When to delete ILayer is Initiated in the below case
What ? You mean you want to know how to delete the ILayer instance that was created by new ?
Well, that depends a lot of what itsSppAst is... It becomes the only owner of the pointer so it is the only one that is able to delete it. If you don't have access to this class, then you will need to store a ILayer instance in your ABC class and create itsSppAst later, after you created your ILayer instance (you will need to use new in that case).
BTW, your indentation is awfull, it took me quite some time to understand your code which is rather simple.
|
|
|
|
|
This question makes little sense. Please elaborate.
--
gleat
http://blogorama.nerdworks.in[ ^]
-- Number Two's eyes narrowed and became what are known in the Shouting and Killing People trade as cold slits, the idea presumably being to give your opponent the impression that you have lost your glasses or are having difficulty keeping awake. Why this is frightening is an, as yet, unresolved problem. -- HHGTG
|
|
|
|