如何调用与类成员同名的函数

时间:2015-11-11 15:46:08

标签: c++ scope scope-resolution

如何从定义具有相同名称public class SimpleDBSearch { public void sdbSearch(Scanner searchWord) throws IOException{ //Prompt user for input System.out.println("Please input the word you wish to find:"); //Init string var containing user input String wordInput = searchWord.next(); //Specify file to search File file = new File("C:/Users/Joshua/Desktop/jOutFiles/TestFile.txt"); //Init Scanner containing specified file Scanner fileScanner = new Scanner(file); //Loops through every line looking for lines containing previously specified string. while(fileScanner.hasNextLine()){ String line = fileScanner.nextLine(); if(line.contains(wordInput)){ //If desired string is found, print line containing it to console System.out.println("I found the word you're looking for here: " + line); }else{ //If desired string not found, prompt user for new string. I want this to occur only once, not per every line-check System.out.println("Please input a new word"); } } } 的成员函数的类中调用非成员函数listen()(包含自sys/socket.h)?

listen()

1 个答案:

答案 0 :(得分:7)

使用范围解析运算符::

void Socket::listen(int port){
    //...
    ::listen(sock_fd, 10);
    ^^
}

范围解析运算符::用于标识和消除不同范围中使用的标识符的歧义。