LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-13-2010, 02:08 AM   #1
mq15
Member
 
Registered: Apr 2009
Location: Pakistan
Distribution: Fedora 9
Posts: 192

Rep: Reputation: 30
Question how to find the scope/definitions of a class/methods ?


In Windows environment when I used Borlan for C/C++ compilation, I was used to find the the scope/definitions of the methods/classes by pressing
Code:
ctrl + F1
when the cursor was hovering on that method/class. How can I find the scopes/definitions in the GNU/Linux?

Code:
//atoi.cc
#include <iostream>

main(int argc, char* argv[]) {
float var_float = atof(argv[0]);
int var_int = atoi(argv[1]);
printf("var_float is %2.1f\nvar_int is %d\n",var_float,var_int);
}
Code:
[mq15@localhost c-c++_files]$ c++ atoi.cc -o atoi
atoi.cc: In function ‘int main(int, char**)’:
atoi.cc:7: error: ‘atof’ was not declared in this scope
atoi.cc:8: error: ‘atoi’ was not declared in this scope
Code:
[mq15@localhost c-c++_files]$ c++ --version
c++ (GCC) 4.3.0 20080428 (Red Hat 4.3.0-8)
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Best Regards
 
Old 02-13-2010, 02:54 AM   #2
carbonfiber
Member
 
Registered: Sep 2009
Location: Sparta
Posts: 237

Rep: Reputation: 46
Code:
$ man atof
$ man atoi
 
Old 02-13-2010, 04:46 AM   #3
mq15
Member
 
Registered: Apr 2009
Location: Pakistan
Distribution: Fedora 9
Posts: 192

Original Poster
Rep: Reputation: 30
Question two more confusions

Thanks.

1.1 If man shows manual of bash commands/utilities, how it is showing the manual of a c/c++ method i.e. atof()?
1.2 If atof() is not a c/c++ method, but it is a bash command/utility, then how we can use a bash command/utility i.e. atof() in a .cpp source file?

2. I have included stdlib.h and atoi.cpp is compiled with no errors, yet the result is not what I expect:
Code:
[mq15@localhost c-c++_files]$ ./atoi 5.4 6
var_float is 0.0
var_int is 5


What I expect is:
Code:
[mq15@localhost c-c++_files]$ ./atoi 5.4 6
var_float is 5.4
var_int is 5


See the cource code of atoi in post#1
Best Regards

Last edited by mq15; 02-13-2010 at 04:52 AM.
 
Old 02-13-2010, 05:11 AM   #4
carbonfiber
Member
 
Registered: Sep 2009
Location: Sparta
Posts: 237

Rep: Reputation: 46
1.1: Magic

1.2: atof is neither a c/c++ class/method nor a bash command/utility

2.0: Of course the result is not what you expect. This is a consequence of the fact that you do not know what argv[0] is supposed to be.

P.S.: Conduct the following experiment: write a C program which prints argv[i] (0 <= i < argc) on separate lines.

Last edited by carbonfiber; 02-13-2010 at 05:14 AM.
 
Old 02-13-2010, 05:43 AM   #5
mq15
Member
 
Registered: Apr 2009
Location: Pakistan
Distribution: Fedora 9
Posts: 192

Original Poster
Rep: Reputation: 30
1.1 Still not satisfied
1.2 Then what atof actually is ?
2.0 Got it now. argv[0] holds the string the file was invoked with, in the terminal.
argv[1], argv[2]...argv[i] are supposed to be string values.

Code:
//arguments.cc
#include <iostream>
#include <stdlib.h>

main(int argc, char* argv[]) {

for(int i=0; i< argc; i++)
	printf("arg[%d] = %s\n",i,argv[i]);
}
Code:
[mq15@localhost c-c++_files]$ ./arguments str 5 6.7
arg[0] = ./arguments
arg[1] = str
arg[2] = 5
arg[3] = 6.7
The main problem is still unsolved: How to find the scope/definition of c++ classes/methods???
For example if I use
Code:
cout<<"Hello World";
, I get
Code:
‘cout’ was not declared in this scope
and doing man cout shows No manual entry for cout

Last edited by mq15; 02-13-2010 at 05:57 AM.
 
Old 03-12-2010, 10:47 AM   #6
nivantha
LQ Newbie
 
Registered: Apr 2006
Distribution: Fedora
Posts: 17

Rep: Reputation: 0
Put this before the main funciton in your c++ code. You'll be able to compile the C++ code

using namespace std;
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
class methods working in background with C++ Guilherme Programming 9 08-27-2009 12:03 PM
Python / using modules in class methods introuble Programming 3 01-16-2007 11:00 AM
scope of an object and global scope lucky6969b Programming 7 12-09-2005 10:09 PM
RSSOwl - Doesn't find class sundaraz Linux - Newbie 1 11-05-2005 04:05 PM
JAVA : cannot find class JFrame? OmniXBro Programming 11 06-04-2004 03:53 AM


All times are GMT -5. The time now is 02:14 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration