Results 1 to 14 of 14
- 06-05-2010, 05:08 PM #1
define object outside the function.
Hello there. I ve stuck with the next problem. I have the class SimpleDriver which include 3 functions. These functions run every milisecond. I have also a class which reads files from txt. I want to read these files in SimpleDriver but outside the functions(as i want to read the files ones). How can i make oject of the the class read_file i have outside the functions in the simpleDriver?
- 06-05-2010, 05:23 PM #2
By saying functions I mean methods of the class.
- 06-05-2010, 06:01 PM #3
Define the variable that refers to the read_file object at the class level in the simpleDriver class. Ie outside of its methods.How can i make oject of the the class read_file i have outside the functions in the simpleDriver
Java Code:class simpleDriver { read_file rdFile; // reference to a read_file object void method1() { } }
- 06-05-2010, 06:23 PM #4
Ok i see what you mean. But also i want to initialize the object for example i will create an instance (read_file a;). And after that i want to open the file
a.OpenfileRead("C/.../.../..txt"); // method in class read_file that open a txt
a.rEaD(); // method that read a txt.
I can only make an object how can initialize it outside the methods of the class SimpleDriver?
- 06-05-2010, 06:38 PM #5
read_file rdFile = new read_file(); // define and assign it a valuehow can initialize it
- 06-05-2010, 06:53 PM #6
Yea if you use constructor of the class it doesnt work it said to me "identifier expected". Basically tou can make a contructor but when you will try to make an instance of method i said before rdFile.OpenFileRead("..."); i have this message.
- 06-05-2010, 07:06 PM #7
Please post full text of error messages. Don't edit them.
- 06-05-2010, 07:35 PM #8
Ok you are right i m very clear with the problem.
I have
the message is cannot find symbol w identifier expected.Java Code:class SimpleDriver{ variables; public double [][] w=null; // i want to parse the txt file into a two dimensional array read_file rdFile = new read_file(); rdFile.OpenReadFile("path"); rdFile.ReaD();// read returns an array with the elements of the txt // so here i ve tried w=rdFile.ReaD(); void methods(){ } }
- 06-05-2010, 07:37 PM #9
Please copy and paste the FULL text of the message. Don't edit it.message is
- 06-05-2010, 07:48 PM #10
I didnt miss something, is exactly the message i have.
- 06-05-2010, 07:58 PM #11
Only that one line? No source line number or program name?
How are you compiling your programs?
- 06-05-2010, 08:50 PM #12
I compile my files in terminal. And i have problems with these lines
rdFile.OpenReadFile("path");
rdFile.ReaD();
- 06-05-2010, 08:54 PM #13
Senior Member
- Join Date
- May 2010
- Posts
- 436
- Rep Power
- 4
Again, post the exact error messages.
- 06-05-2010, 09:00 PM #14
Similar Threads
-
When to define object and when to use "new" only
By Hossein in forum New To JavaReplies: 7Last Post: 04-22-2010, 09:03 AM -
define a variable
By jperson in forum New To JavaReplies: 2Last Post: 01-29-2010, 02:33 AM -
Possible? Callback function passed as arguments to another function
By TreyAU21 in forum Advanced JavaReplies: 3Last Post: 12-04-2009, 03:08 PM -
Define this error.
By jaicea in forum New To JavaReplies: 3Last Post: 12-02-2009, 01:07 AM -
Passing a Vector object to a function
By evapisces in forum New To JavaReplies: 4Last Post: 09-27-2008, 03:18 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks