<style>blockquote {padding-left: 1ex; margin: 0px 0px 0px 0.8ex; border-left: #cccccc 1px solid;} p {margin: 0px;padding: 0px;} </style>
<p>Hi all!</p>
<p> </p>
<p>I have a class:</p>
<p> </p>
<pre class="lang-c prettyprint"><code><span class="kwd">class</span><span class="pln"> </span><span class="typ">UserImpl</span><span class="pln"> </span><span class="pun">:</span><span class="pln"> </span><span class="kwd">public</span><span class="pln"> POA_User<br /></span><span class="pun">{</span><span class="pln"><br /> </span><span class="kwd">private</span><span class="pln"> </span><span class="pun">:</span><span class="pln"><br /> typedef <br
/>vector<GroupImpl*> Groups;<br /> Groups groups;</span><span class="pln"><br /> </span><span class="kwd">public</span><span class="pln"> </span><span class="pun">:</span><span class="pln"><br /><br /> </span><span class="typ">User</span><span class="pun">::</span><span class="typ">Groups</span><span class="pun">*</span><span class="pln"> getGroups</span><span class="pun">();</span><span class="pln"><br /> <br />
</span><span class="kwd">void</span><span class="pln"> setGroups</span><span class="pun">(</span><span class="kwd">const</span><span class="pln"> </span><span class="pun">::</span><span class="typ">User</span><span class="pun">::</span><span class="typ">Groups</span><span class="pun">&</span><span class="pln"> g</span><span class="pun">);</span><span class="pln"><br /></span><span class="pun">};</span><span class="pln"><br /><br /></span><span
class="com">#endif</span><span>class="pln"><br /><br /></span><span class="com">#include</span><span class="pln"> </span><span class="str">"UserImpl.h"</span><span class="pln"><br /><br /></span><span class="typ">User</span><span class="pun">::</span><span class="typ">Groups</span><span class="pun">*</span><span class="pln"> </span><span class="typ">UserImpl</span><span class="pun">::</span><span class="pln">getGroups</span><span class="pun">()</span><span class="pln"><br /></span><span
class="pun">{</span><span>class="pln"><br /> </span><span class="kwd">const size_t size = this->groups.size();<br /> User::Groups_var seqOfObjects = new User::Groups(size);<br /> seqOfObjects->length(size);<br /><br /> size_t i = 0;<br /> vector<GroupImpl*>::const_iterator it = groups.begin();<br /> while (it != groups.end())<br /> {<br /> seqOfObjects[i] = Group::_duplicate((*it)->_this());<br /> ++it;<br /> ++i;<br />
}<br /><br /> return <br />seqOfObjects._retn();</span><span class="pln"><br /></span><span class="pun">}</span><span class="pln"><br /><br /></span><span class="kwd">void UserImpl::setGroups(const ::User::Groups& g)<br />{<br /> const size_t size = g.length();<br /> this->groups.resize(size);<br /> this->groups.clear();<br /><br /> for(size_t i = 0; i<size; i++)<br /> {<br /> GroupImpl *newGroup = new GroupImpl(g[i]->getID(), g[i]->getName(),<br />
<br /> g[i]->getDescript_ion(),g[i]->getFounder(),<br /> *(g[i]->getUsers()));<br /> this->groups.push_back(Groups::value_type(newGroup));<br /> }<br />}<br /><br />And I have some troubles how to write a getter and setter for my class field "groups". I did it, but I have dooubts <br />if it's a good way to do this. It compiles with no error but I'm a beginner in CORBA and would like to<br
/>someone <br />who knows it good help me. Thanks, mazix</span></code></pre><br />