Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Is there any rule on adding class scope in its member function?

19 views
Skip to first unread message

fl

unread,
Oct 31, 2015, 11:09:20 AM10/31/15
to
Hi,

I notice that the return value 'ret_lines' definition has no scope 'TextQuery'
as the internal variable 'has_val'. Is there any rule on such usage?


Thanks,


..........
// returns lines not in its operand's result set
set<TextQuery::line_no>
NotQuery::eval(const TextQuery& file) const
{
// virtual call through the Query handle to eval
set<TextQuery::line_no> has_val = query.eval(file);

set<line_no> ret_lines;

// for each line in the input file, check whether that line is in has_val
// if not, add that line number to ret_lines
for (TextQuery::line_no n = 0; n != file.size(); ++n)
if (has_val.find(n) == has_val.end())
ret_lines.insert(n);
return ret_lines;
}

Öö Tiib

unread,
Oct 31, 2015, 11:52:15 AM10/31/15
to
On Saturday, 31 October 2015 17:09:20 UTC+2, fl wrote:
> Hi,
>
> I notice that the return value 'ret_lines' definition has no scope 'TextQuery'
> as the internal variable 'has_val'. Is there any rule on such usage?
>
>
> Thanks,


You posted a slice of code that does not compile with C++ compiler
and what it means depends on code that you did not post.
We do not know what type names 'line_no' and 'TextQuery::line_no'
represent; seems these are aliases to some integer type.

Paavo Helde

unread,
Oct 31, 2015, 12:32:19 PM10/31/15
to
fl <rxj...@gmail.com> wrote in
news:63166e16-eae7-4e70...@googlegroups.com:

> Hi,
>
> I notice that the return value 'ret_lines' definition has no scope
> 'TextQuery' as the internal variable 'has_val'. Is there any rule on
> such usage?
>
>
> Thanks,
>
>
> ..........
> // returns lines not in its operand's result set
> set<TextQuery::line_no>
> NotQuery::eval(const TextQuery& file) const
> {
> // virtual call through the Query handle to eval
> set<TextQuery::line_no> has_val = query.eval(file);
>
> set<line_no> ret_lines;

As far as we know from this excerpt, the names TextQuery::line_no and
line_no may refer to different types, or they may not. For example, if
TextQuery is a class and NotQuery is inherited from TextQuery, they would
most probably refer to the same type.

A decent programming IDE would provide you with a 'go to definition'
feature which would help you to see (with some confidence) if they are
the same or not.

hth
Paavo

fl

unread,
Oct 31, 2015, 12:58:51 PM10/31/15
to
On Saturday, October 31, 2015 at 12:32:19 PM UTC-4, Paavo Helde wrote:
> fl <rx...@gmail.com> wrote in
> news:63166e16-eae7-x0-...@googlegroups.com:
Thanks both of you. Both types have its respective typedef's. They are
different.
0 new messages