473,387 Members | 1,535 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,387 software developers and data experts.

Counting array probelm

384 256MB
I have this code:
Expand|Select|Wrap|Line Numbers
  1. int totalNumberOfGames = games.totalGames;
games is a class and its has this function in it:
Expand|Select|Wrap|Line Numbers
  1. public int totalGames()
  2. { return processNames.Count(); }
It gives me this error when i try to build it:
Error 1 Cannot convert method group 'totalGames' to non-delegate type 'int'. Did you intend to invoke the method? C:\Documents and Settings\admin\Desktop\Project\Test\Test\frmMain.c s 98 42 Test
Sep 20 '08 #1
6 1411
kenobewan
4,871 Expert 4TB
I assume that this is because totalgames is being returned as a string. Trying converting to an integer.
Sep 20 '08 #2
mldisibio
190 Expert 100+
Try:
Expand|Select|Wrap|Line Numbers
  1. int totalNumberOfGames = games.totalGames();
Eliminating the parens confuses the compiler into interpreting the method call as a delegate, which it is not.
Sep 20 '08 #3
ziycon
384 256MB
Try:
Expand|Select|Wrap|Line Numbers

1. int totalNumberOfGames = games.totalGames();


Eliminating the parens confuses the compiler into interpreting the method call as a delegate, which it is not.
Tired that but getting this error now:
Error 1 An object reference is required for the non-static field, method, or property 'Test.games.totalGames()' C:\Documents and Settings\admin\Desktop\Project\Test\Test\frmMain.c s 98 42 Test
Sep 24 '08 #4
Plater
7,872 Expert 4TB
Yup that is correct.
Either instanciate your class and use the object to make your totalGames() or declare it as a static function (assuming it does not rely on any member varriables)

While you're at it, I also recomend picking up a tutorial on object oriented programming (OOP), because this is all pretty basic level in there.
Sep 24 '08 #5
mldisibio
190 Expert 100+
If games is a class you need either:
A. to have an instance of it
Expand|Select|Wrap|Line Numbers
  1. games MyGames =  new games();
  2. int totalNumberOfGames = MyGames.totalGames();
  3.  
or make totalGames a static method:
Expand|Select|Wrap|Line Numbers
  1. class games {
  2.   public static int totalGames()  { return processNames.Count(); }
  3. }
  4.  
  5. int totalNumberOfGames = games.totalGames();
  6.  
Sep 24 '08 #6
ziycon
384 256MB
Yup that is correct.
Either instanciate your class and use the object to make your totalGames() or declare it as a static function (assuming it does not rely on any member varriables)

While you're at it, I also recomend picking up a tutorial on object oriented programming (OOP), because this is all pretty basic level in there.
Thanks for that, its been a year since i've done proper coding and over looked the creating an instance. It'll come back to me(Hopefully). Thanks again.
Sep 24 '08 #7

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

Similar topics

7
by: Sam Lowry | last post by:
Greetings. I am trying to do something which should elementary for Perl, but I have only been able to find bits and pieces on it. When I put the bits together they do not work. Maybe I am going...
9
by: NiQ | last post by:
Hello every one, this is about an array of string and may be have done several time before but i need it and wasnt able to find it so here is the problem i have an array of strings with contains...
14
by: Mike N. | last post by:
Hello: I have a form that contains a multiple-select field that has 12 options in it. I would like the user to be able to select UP TO FOUR of those options. If they select more than four, I...
8
by: DrNoose | last post by:
Hi! I'm writing a program that is supposed to read a line of input, count the words and the number of occurrences of each letter. Then it should prints the number of occurrences of each letter...
4
by: Rob Meade | last post by:
Hi all, Ok - I appreciated I could probably just do this : For Each item IN array intCount = intCount + 1 Next
5
by: andy.lee23 | last post by:
hi im having trouble counting lines in a text file, i have the following code int node1, node2, i; char name; float value; ifstream fin; fin.open(OpenDialog1->FileName.c_str()); i=1;
10
by: Tony Young | last post by:
Hi, I have an array of integer. I need to find the max of the 0th, 3th, 6th , 9th, ... elements in the array. I wonder if STL (standard template library) provides a way to manipulate only part...
0
by: Marc | last post by:
Guys , the below code is a VB project working woth mappoint. My probelm is with the very last section of code not working ----'Set oShp = objMap.Shapes.AddPolyline(objLoc2). Im not sure i...
5
by: k4m135h | last post by:
Hi, I've come across a problem where i seem to be doing the counting of numbers in a inefficient way i've got a 200x200 array with numbers ranging from 101-600 and also 0 and 1. and i need to count...
4
by: frizzle | last post by:
Hi there, I have a function to create an array of all files in a certain folder, so i can display the structure. The actual function is below the message, as is an example of its output. As...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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.