Pointer for class not working that well. Syntax I think.


 
Thread Tools Search this Thread
Top Forums Programming Pointer for class not working that well. Syntax I think.
# 1  
Old 12-20-2010
Pointer for class not working that well. Syntax I think.

I'll be gratefull for any help. Thanks.
Smilie
This is the non class type error:
[root@dsgfedora01 dsgsports]# g++ -I/usr/include/mysql -I/usr/include/mysql++ -lmysqlpp -L/usr/lib/mysql -L/usr/local/lib/mysql++ loaddsgsports.cpp -o loaddsgsports
loaddsgsports.cpp: In function âint outputToImport(const char*, const char*, mysqlpp::Connection*)â:
loaddsgsports.cpp:13:33: error: request for member âqueryâ in âpconnâ, which is of non-class type âmysqlpp::Connection*â

This is my code:
#include </usr/include/mysql++/mysql++.h>
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <string.h>
using namespace std;


int outputToImport(const char* tbl_name, const char* output, mysqlpp::Connection* pconn) {
char squery[512];
sprintf(squery,"TRUNCATE TABLE %s;", tbl_name);
std::cout << squery << std::endl;
mysqlpp::Query pquery = pconn.query(squery);

}

int main()
{
mysqlpp::Connection conn(false);

if (conn.connect("dsgsports","127.0.0.1" , "root", "")) {
printf("Connected to database.\n");
}
else {
printf("Failed to connect to database.");
return 1;
}
outputToImport("aa","aa", &conn);
return 0;
}
# 2  
Old 12-20-2010
Very very close. You don't use . on pointers, you use ->, so: pconn->query(squery);

What's "output" for, by the way?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sum working but getting syntax error - awk

Hi, I am using the following command to get the sum and it is working correctly but I am getting syntax error as well. # ------------------------------------------------------------------------ # Adding awk command support for SunOS -- use nawk for SunOS #... (3 Replies)
Discussion started by: uuuunnnn
3 Replies

2. Shell Programming and Scripting

Syntax Error in AIX but working in UX

MENU_INTRO(){ date="`date`" HOSTNAME="`hostname`" if ; then cols=$2 else cols=2 fi clear now=`date +%A,%B-%d-%Y@%H:%M:%S` echo " -: INFORMIX DBA MENU :- " echo... (1 Reply)
Discussion started by: fedora132010
1 Replies

3. Programming

Python (seleniumrequests)Class, Constructor, Method Not Working

Newbie question. I created a class: class WP(seleniumrequests.PhantomJS): def __init__(self, wpurl='https://blah.org/download/release-archive/', bwppurl='https://blah.org/plugins/browse/popular/'): self.wp=wpurl ... (5 Replies)
Discussion started by: metallica1973
5 Replies

4. Programming

C++ : Base class member function not accessible from derived class

Hello All, I am a learner in C++. I was testing my inheritance knowledge with following piece of code. #include <iostream> using namespace std; class base { public : void display() { cout << "In base display()" << endl; } void display(int k) {... (2 Replies)
Discussion started by: anand.shah
2 Replies

5. Programming

Size of Derived class, upon virtual base class inheritance

I have the two class definition as follows. class A { public: int a; }; class B : virtual public A{ }; The size of class A is shown as 4, and size of class B is shown as 16. Why is this effect ?. (2 Replies)
Discussion started by: techmonk
2 Replies

6. Shell Programming and Scripting

Shell script check syntax not working ...

Hello i have question that i want check syntax from my script shell with sh -n filename but it's not show something even i have wrong syntax in my file. why can this happened or any other way to check it? i use on header of file : #!/bin/sh thx before :) (7 Replies)
Discussion started by: Gochengz
7 Replies

7. UNIX for Advanced & Expert Users

Get pointer for existing device class (struct class) in Linux kernel module

Hi all! I am trying to register a device in an existing device class, but I am having trouble getting the pointer to an existing class. I can create a class in a module, get the pointer to it and then use it to register the device with: *cl = class_create(THIS_MODULE, className);... (0 Replies)
Discussion started by: hdaniel@ualg.pt
0 Replies

8. Programming

Class Pointer initialization C++

Hello everyone, I have a question, that are the following ways of pointer intialization same ? ClassA *point; point = 0; point = new ClassA; Thanks a load in advance!! Regards, (10 Replies)
Discussion started by: mind@work
10 Replies

9. Shell Programming and Scripting

for loop not working - syntax error at line 6: `end of file' unexpected

I have a file called test.dat which contains a b I have written a shell script called test.sh for i in `cat test.dat` do echo $i done When i run this script using sh test.sh I get this message - test.sh: syntax error at line 6: `end of file' unexpected What is the... (3 Replies)
Discussion started by: debojyoty
3 Replies

10. Programming

pass a pointer-to-pointer, or return a pointer?

If one wants to get a start address of a array or a string or a block of memory via a function, there are at least two methods to achieve it: (1) one is to pass a pointer-to-pointer parameter, like: int my_malloc(int size, char **pmem) { *pmem=(char *)malloc(size); if(*pmem==NULL)... (11 Replies)
Discussion started by: aaronwong
11 Replies
Login or Register to Ask a Question