LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-01-2003, 05:13 PM   #1
dhanakom
LQ Newbie
 
Registered: Jul 2003
Location: Birmingham
Posts: 20

Rep: Reputation: 0
specifying a prototype


Hi,

suppose i want to say my function will return the base address of an array of type T, my prototype will look like this

T (*) [] getRowAddress();

I'am using templates so T will have appropriate data type

i believe when i declare a pointer to an row of integers (array), i will use

int (*a) [n];

Going by this, my function prototyping should be correct. Please correct me if I'am wrong.

Thanks,
 
Old 09-01-2003, 06:25 PM   #2
dhanakom
LQ Newbie
 
Registered: Jul 2003
Location: Birmingham
Posts: 20

Original Poster
Rep: Reputation: 0
correction

i think i should have said

T (&) [] getNoRows();

but this is no good, complier cries when it sees this declaration. please lemme know whats going wrong.

Thanks.
 
Old 09-02-2003, 03:07 AM   #3
devoyage
Member
 
Registered: Aug 2003
Distribution: many
Posts: 37

Rep: Reputation: 15
Why not just use
Code:
T *foo1();
if you want to return a pointer to the first index of an array, and
Code:
T **foo2();
if you want to return a pointer to the pointer to the first index of an array.

I guess these would look something like:
Code:
T *foo(){
    int x[5];
return(x);
}

T **foo2(){
    int x[5];
return(&x);
}
respectively.

I think you are making this all more complicated than it need be.

good luck
 
  


Reply



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
How many prototype of function main in c? ypzhuang Programming 9 12-13-2008 07:53 AM
GLib g_date_set_dmy () prototype info. Thetargos Programming 0 07-15-2004 06:46 PM
Assembly for Rapid Prototype mikeshn Programming 1 03-09-2002 04:18 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:47 AM.

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
Open Source Consulting | Domain Registration