473,395 Members | 2,689 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Using Pointers on Vectors in C++ (Call by Reference from Funtion to Function)

nabh4u
62
Hi,

I have a problem referencing to Vectors using pointers i.e. I am not able to use "call by reference" on vector variables.

I have a "read()" function in "x.cpp" and "main()" in "y.cpp". I have 3 vector variables in Main(). I want the read function to read the values into the vector using the address I send of the vectors..

Sample code:

Expand|Select|Wrap|Line Numbers
  1. //x.cpp
  2. void read(vector <int> a,vector <int> b,vector < vector <int> > c)
  3. {
  4. //a, b, c are vector variables referencing to the vectors in main of y.cpp
  5.  
  6. }
  7. //y.cpp
  8. void main()
  9. {
  10.       vector <int> a;
  11.       vector <int> b;
  12.       vector < vector <int> > c;
  13.  
  14.       read(&a,&b,&c);
  15.       //Sending the reference to read function in x.cpp to modify data in main
  16. }

I got a LNK#### error where # are numbers.

How do I get this program of mine to read values into the vectors by using references?

I need help as soon as possible

Thank You in Advance..
Feb 11 '07 #1
1 2430
horace1
1,510 Expert 1GB
you need to indicated that the parameters to read() are pointers to vectors, e.g.
Expand|Select|Wrap|Line Numbers
  1. void read(vector <int> *a,vector <int> *b,vector < vector <int> > *c)
  2.  
you are using C++ why not use reference parameters?
Feb 11 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: Christof Krueger | last post by:
Hello, I'm quite new to C++ so maybe there's something I miss. I write a simple board game. It has a board class. This class has a method that returns the count of pieces a player has on the...
1
by: Kalyan | last post by:
Hello, The following posting was made on this newsgroup some 2 yrs ago. Is this still true with the present release of .net. Because I get the exact same exception thrown "Function pointer not...
4
by: Creighton Hogg | last post by:
Hi, I'm having a problem that's driving me nuts right now. I wanted to represent data as a vector<vector<vector<unsigned short> > > Now I've been having alot of trouble initializing and...
20
by: Joe Van Dyk | last post by:
Is there some rule of thumb about when to use pointers to an object and when to use a reference* to an object when a class needs to have objects as data members? Example: class A { B* b_ptr;...
7
by: Eli Luong | last post by:
Hi, Sorry if I accidentally posted a blank post before. But, I was wondering, I'm practicing with pointers right now, and wanted to know if I am using it correctly in the following code. By...
3
by: PolkaHead | last post by:
I was wondering if there's a way to traverse a two-dimensional vector (vector of vectors) with a nested for_each call. The code included traverses the "outer" vector with a for_each, than it...
29
by: shuisheng | last post by:
Dear All, The problem of choosing pointer or reference is always confusing me. Would you please give me some suggestion on it. I appreciate your kind help. For example, I'd like to convert a...
3
Digital Don
by: Digital Don | last post by:
I have a problem sending the Vectors as Referencial parameters..i.e. I am having a struct vector struct board { int r; int c; };
1
by: ohaqqi | last post by:
Hi guys, I'm still working on my shell. I'm trying to implement a function typefile that will take a command line input as follows: > type <file1> This command will implement a catenation of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.